Improve update and migration flow
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Create a new Omarchy migration in the current source tree.
|
||||
# omarchy:args=<system|user> [--no-edit]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
scope="${1:-}"
|
||||
case "$scope" in
|
||||
system|user)
|
||||
shift
|
||||
;;
|
||||
-h|--help|"")
|
||||
echo "Usage: omarchy-dev-add-migration <system|user> [--no-edit]"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown migration scope: $scope" >&2
|
||||
echo "Usage: omarchy-dev-add-migration <system|user> [--no-edit]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
cd "${OMARCHY_PATH:-$(pwd)}"
|
||||
mkdir -p migrations
|
||||
migration_file="migrations/$(git log -1 --format=%cd --date=unix).sh"
|
||||
mkdir -p "migrations/$scope"
|
||||
migration_file="migrations/$scope/$(git log -1 --format=%cd --date=unix).sh"
|
||||
touch "$migration_file"
|
||||
|
||||
if [[ ${1:-} != "--no-edit" ]]; then
|
||||
|
||||
@@ -18,7 +18,7 @@ For shipped configs see /etc/skel (new users) and omarchy-reinstall-configs
|
||||
(existing users explicitly resyncing).
|
||||
|
||||
--first-install is used by the ISO in the target chroot. It marks shipped
|
||||
migrations complete for the freshly-created user.
|
||||
user migrations complete for the freshly-created user.
|
||||
|
||||
Idempotency marker: ~/.local/state/omarchy/finalize-user.done
|
||||
USAGE
|
||||
@@ -123,9 +123,9 @@ xdg-settings set default-web-browser chromium.desktop
|
||||
xdg-mime default HEY.desktop x-scheme-handler/mailto
|
||||
|
||||
if (( first_install )); then
|
||||
mkdir -p "$state_dir/migrations"
|
||||
for migration in "$OMARCHY_PATH"/migrations/*.sh; do
|
||||
[[ -f $migration ]] && touch "$state_dir/migrations/$(basename "$migration")"
|
||||
mkdir -p "$state_dir/migrations/user"
|
||||
for migration in "$OMARCHY_PATH"/migrations/user/*.sh; do
|
||||
[[ -f $migration ]] && touch "$state_dir/migrations/user/$(basename "$migration")"
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
@@ -92,6 +92,17 @@ run_first_run_step() {
|
||||
fi
|
||||
}
|
||||
|
||||
wait_for_notifications
|
||||
|
||||
MIGRATION_NOTIFY_WATCH_MARKER="$state_dir/user-migration-notify-watch-enabled"
|
||||
if [[ ! -f $MIGRATION_NOTIFY_WATCH_MARKER || $force -eq 1 ]]; then
|
||||
if systemctl --user enable --now omarchy-update-user-notify.path >/dev/null 2>&1; then
|
||||
touch "$MIGRATION_NOTIFY_WATCH_MARKER"
|
||||
fi
|
||||
fi
|
||||
|
||||
run_first_run_step "notify about pending user migrations" omarchy-migrate-notify
|
||||
|
||||
USER_MARKER="$state_dir/first-run-user.done"
|
||||
if [[ ! -f $USER_MARKER || $force -eq 1 ]]; then
|
||||
run_first_run_step "install Voxtype post-update hook" \
|
||||
|
||||
+89
-11
@@ -1,19 +1,97 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Run pending Omarchy migrations for the current user.
|
||||
# omarchy:summary=Run pending Omarchy system and user migrations.
|
||||
# omarchy:args=[--pending [all|system|user]]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
STATE_DIR="$HOME/.local/state/omarchy/migrations"
|
||||
mkdir -p "$STATE_DIR"
|
||||
mode="run"
|
||||
pending_scope="all"
|
||||
|
||||
for file in "$OMARCHY_PATH"/migrations/*.sh; do
|
||||
[[ -f $file ]] || continue
|
||||
filename=$(basename "$file")
|
||||
usage() {
|
||||
echo "Usage: omarchy-migrate [--pending [all|system|user]]"
|
||||
}
|
||||
|
||||
if [[ ! -f $STATE_DIR/$filename ]]; then
|
||||
echo -e "\e[32m\nRunning migration (${filename%.sh})\e[0m"
|
||||
bash "$file"
|
||||
touch "$STATE_DIR/$filename"
|
||||
fi
|
||||
while (($#)); do
|
||||
case "$1" in
|
||||
--pending|--check)
|
||||
mode="pending"
|
||||
shift
|
||||
if [[ ${1:-} == "all" || ${1:-} == "system" || ${1:-} == "user" ]]; then
|
||||
pending_scope="$1"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--pending=all|--pending=system|--pending=user)
|
||||
mode="pending"
|
||||
pending_scope="${1#--pending=}"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
pending_output=""
|
||||
|
||||
append_pending() {
|
||||
local scope="$1"
|
||||
local command="$2"
|
||||
local output=""
|
||||
local migration=""
|
||||
|
||||
if output=$("$command" --pending 2>/dev/null); then
|
||||
while IFS= read -r migration; do
|
||||
[[ -n $migration ]] || continue
|
||||
pending_output+="$scope/$migration"$'\n'
|
||||
done <<<"$output"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $mode == "pending" ]]; then
|
||||
case "$pending_scope" in
|
||||
all)
|
||||
append_pending system omarchy-migrate-system
|
||||
append_pending user omarchy-migrate-user
|
||||
;;
|
||||
system)
|
||||
append_pending system omarchy-migrate-system
|
||||
;;
|
||||
user)
|
||||
append_pending user omarchy-migrate-user
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -n $pending_output ]]; then
|
||||
printf '%s' "$pending_output"
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
wait_for_pacman_transaction() {
|
||||
local lock_file=/var/lib/pacman/db.lck
|
||||
|
||||
[[ -e $lock_file ]] || return 0
|
||||
echo "Waiting for pacman transaction to finish before running Omarchy migrations..."
|
||||
|
||||
for _ in {1..900}; do
|
||||
[[ -e $lock_file ]] || return 0
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Pacman transaction is still running; Omarchy migrations will retry on next login."
|
||||
exit 0
|
||||
}
|
||||
|
||||
wait_for_pacman_transaction
|
||||
|
||||
omarchy-migrate-system
|
||||
omarchy-migrate-user
|
||||
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Notify the user when Omarchy has pending user migrations
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
pending_migrations=$(omarchy-migrate --pending user 2>/dev/null) || exit 0
|
||||
pending_count=$(printf '%s\n' "$pending_migrations" | sed '/^[[:space:]]*$/d' | wc -l)
|
||||
|
||||
if (( pending_count == 1 )); then
|
||||
message="1 new Omarchy user migration is available. Click to run it in a terminal."
|
||||
else
|
||||
message="$pending_count new Omarchy user migrations are available. Click to run them in a terminal."
|
||||
fi
|
||||
|
||||
notify_command=$(printf 'if [[ -n $(omarchy-notification-send -u critical -g "Run Omarchy Migrations" %q -a) ]]; then omarchy-launch-floating-terminal-with-presentation omarchy-migrate; fi' "$message")
|
||||
|
||||
if command -v systemd-run >/dev/null 2>&1; then
|
||||
unit="omarchy-migrations-notification-$(date +%Y%m%d%H%M%S)"
|
||||
systemd-run --user --scope --unit="$unit" bash -lc "$notify_command" >/dev/null 2>&1 && exit 0
|
||||
fi
|
||||
|
||||
print_pending_migrations() {
|
||||
echo "Omarchy has pending user migrations. Run omarchy-migrate in a terminal to apply them:"
|
||||
while IFS= read -r migration; do
|
||||
[[ -n $migration ]] || continue
|
||||
printf ' %s\n' "$migration"
|
||||
done <<<"$pending_migrations"
|
||||
}
|
||||
|
||||
if [[ -t 1 ]]; then
|
||||
print_pending_migrations
|
||||
else
|
||||
print_pending_migrations >&2
|
||||
fi
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Run pending Omarchy system migrations as root.
|
||||
# omarchy:args=[--pending]
|
||||
# omarchy:requires-sudo=true
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
mode="run"
|
||||
while (($#)); do
|
||||
case "$1" in
|
||||
--pending|--check)
|
||||
mode="pending"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: omarchy-migrate-system [--pending]"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
|
||||
STATE_DIR="${OMARCHY_SYSTEM_MIGRATION_STATE:-/var/lib/omarchy/migrations/system}"
|
||||
MIGRATIONS_DIR="$OMARCHY_PATH/migrations/system"
|
||||
|
||||
pending_migrations() {
|
||||
[[ -d $MIGRATIONS_DIR ]] || return 0
|
||||
|
||||
for file in "$MIGRATIONS_DIR"/*.sh; do
|
||||
[[ -f $file ]] || continue
|
||||
filename=$(basename "$file")
|
||||
|
||||
if [[ ! -f $STATE_DIR/$filename ]]; then
|
||||
printf '%s\n' "$filename"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [[ $mode == "pending" ]]; then
|
||||
pending_output=$(pending_migrations)
|
||||
if [[ -n $pending_output ]]; then
|
||||
printf '%s\n' "$pending_output"
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if (( EUID != 0 )) && [[ -z ${OMARCHY_SYSTEM_MIGRATION_STATE:-} ]]; then
|
||||
if ! "$0" --pending >/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exec sudo --preserve-env=OMARCHY_PATH "$0" "$@"
|
||||
fi
|
||||
|
||||
mkdir -p "$STATE_DIR"
|
||||
[[ -d $MIGRATIONS_DIR ]] || exit 0
|
||||
|
||||
for file in "$MIGRATIONS_DIR"/*.sh; do
|
||||
[[ -f $file ]] || continue
|
||||
filename=$(basename "$file")
|
||||
|
||||
if [[ ! -f $STATE_DIR/$filename ]]; then
|
||||
echo -e "\e[32m\nRunning system migration (${filename%.sh})\e[0m"
|
||||
OMARCHY_PATH="$OMARCHY_PATH" bash -euo pipefail "$file"
|
||||
touch "$STATE_DIR/$filename"
|
||||
fi
|
||||
done
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Run pending Omarchy migrations for the current user.
|
||||
# omarchy:args=[--pending]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
mode="run"
|
||||
while (($#)); do
|
||||
case "$1" in
|
||||
--pending|--check)
|
||||
mode="pending"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: omarchy-migrate-user [--pending]"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
|
||||
STATE_DIR="${OMARCHY_USER_MIGRATION_STATE:-$HOME/.local/state/omarchy/migrations/user}"
|
||||
MIGRATIONS_DIR="$OMARCHY_PATH/migrations/user"
|
||||
|
||||
pending_migrations() {
|
||||
[[ -d $MIGRATIONS_DIR ]] || return 0
|
||||
|
||||
for file in "$MIGRATIONS_DIR"/*.sh; do
|
||||
[[ -f $file ]] || continue
|
||||
filename=$(basename "$file")
|
||||
|
||||
if [[ ! -f $STATE_DIR/$filename ]]; then
|
||||
printf '%s\n' "$filename"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [[ $mode == "pending" ]]; then
|
||||
pending_output=$(pending_migrations)
|
||||
if [[ -n $pending_output ]]; then
|
||||
printf '%s\n' "$pending_output"
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$STATE_DIR"
|
||||
[[ -d $MIGRATIONS_DIR ]] || exit 0
|
||||
|
||||
for file in "$MIGRATIONS_DIR"/*.sh; do
|
||||
[[ -f $file ]] || continue
|
||||
filename=$(basename "$file")
|
||||
|
||||
if [[ ! -f $STATE_DIR/$filename ]]; then
|
||||
echo -e "\e[32m\nRunning user migration (${filename%.sh})\e[0m"
|
||||
OMARCHY_PATH="$OMARCHY_PATH" bash -euo pipefail "$file"
|
||||
touch "$STATE_DIR/$filename"
|
||||
fi
|
||||
done
|
||||
@@ -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 pacman -Syyuu --noconfirm
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -Syyuu --noconfirm
|
||||
|
||||
@@ -11,8 +11,8 @@ set -e
|
||||
omarchy-refresh-pacman
|
||||
|
||||
# Downgrade any packages to the stable setup
|
||||
sudo pacman -Suu --noconfirm
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -Suu --noconfirm
|
||||
|
||||
# Ensure all packages are installed
|
||||
mapfile -t packages < <(grep -v '^#' "$OMARCHY_PATH/install/omarchy-base.packages" | grep -v '^$')
|
||||
sudo pacman -Syu --noconfirm --needed "${packages[@]}"
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -Syu --noconfirm --needed "${packages[@]}"
|
||||
|
||||
+88
-2
@@ -7,14 +7,100 @@
|
||||
|
||||
set -e
|
||||
|
||||
if [[ -z $OMARCHY_UPDATE_LOGGED ]]; then
|
||||
if [[ -z ${OMARCHY_UPDATE_LOGGED:-} ]]; then
|
||||
script_command=$(printf '%q ' "$0" "$@")
|
||||
exec env OMARCHY_UPDATE_LOGGED=1 script -qefc "$script_command" "/tmp/omarchy-update.log"
|
||||
fi
|
||||
|
||||
acquire_update_lock() {
|
||||
local lock_dir="${XDG_RUNTIME_DIR:-/tmp}"
|
||||
local lock_path="$lock_dir/omarchy-update.lock"
|
||||
local lock_fd_path=""
|
||||
|
||||
mkdir -p "$lock_dir" 2>/dev/null || true
|
||||
|
||||
if [[ -n ${OMARCHY_UPDATE_LOCK_FD:-} && -e /proc/$$/fd/$OMARCHY_UPDATE_LOCK_FD ]]; then
|
||||
lock_fd_path=$(readlink -f "/proc/$$/fd/$OMARCHY_UPDATE_LOCK_FD" 2>/dev/null || true)
|
||||
if [[ $lock_fd_path == "$(readlink -m "$lock_path")" ]] && flock -n "$OMARCHY_UPDATE_LOCK_FD"; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
exec {OMARCHY_UPDATE_LOCK_FD}>"$lock_path"
|
||||
if ! flock -n "$OMARCHY_UPDATE_LOCK_FD"; then
|
||||
echo "An Omarchy update is already running."
|
||||
exit 1
|
||||
fi
|
||||
export OMARCHY_UPDATE_LOCK_FD
|
||||
}
|
||||
|
||||
update_disabled_idle=0
|
||||
sleep_inhibit_pid=""
|
||||
|
||||
disable_sleep_for_update() {
|
||||
command -v systemd-inhibit >/dev/null 2>&1 || return 0
|
||||
|
||||
systemd-inhibit \
|
||||
--what=sleep:idle \
|
||||
--who=omarchy-update \
|
||||
--why="Omarchy update in progress" \
|
||||
--mode=block \
|
||||
sleep infinity >/dev/null 2>&1 &
|
||||
sleep_inhibit_pid=$!
|
||||
}
|
||||
|
||||
disable_idle_for_update() {
|
||||
local stay_awake_state="$HOME/.local/state/omarchy/indicators/stay-awake"
|
||||
|
||||
if [[ ! -f $stay_awake_state ]]; then
|
||||
omarchy-toggle-idle stay-awake >/dev/null 2>&1 || true
|
||||
update_disabled_idle=1
|
||||
fi
|
||||
}
|
||||
|
||||
restore_update_inhibitors() {
|
||||
if (( update_disabled_idle )); then
|
||||
omarchy-toggle-idle allow-idle >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if [[ -n $sleep_inhibit_pid ]]; then
|
||||
kill "$sleep_inhibit_pid" >/dev/null 2>&1 || true
|
||||
wait "$sleep_inhibit_pid" >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
run_update_pipeline() {
|
||||
disable_sleep_for_update
|
||||
disable_idle_for_update
|
||||
|
||||
omarchy-update-keyring
|
||||
omarchy-update-system-pkgs
|
||||
omarchy-migrate
|
||||
omarchy-hook post-update
|
||||
omarchy-update-aur-pkgs
|
||||
omarchy-update-mise
|
||||
omarchy-update-orphan-pkgs
|
||||
|
||||
omarchy-update-analyze-logs
|
||||
|
||||
# Re-check after updates so the status bar reflects any remaining updates.
|
||||
# This clears the state when everything is current, so a separate reset command
|
||||
# is not needed.
|
||||
if omarchy-update-available >/dev/null; then
|
||||
omarchy-shell -q omarchy.system-update refresh
|
||||
else
|
||||
omarchy-shell -q omarchy.system-update clear
|
||||
fi
|
||||
|
||||
omarchy-update-restart
|
||||
}
|
||||
|
||||
acquire_update_lock
|
||||
|
||||
trap restore_update_inhibitors EXIT
|
||||
trap 'echo ""; echo -e "\033[0;31mSomething went wrong during the update!\n\nPlease review the output above carefully, correct the error, and retry the update.\n\nIf you need assistance, get help from the community at https://omarchy.org/discord\033[0m"' ERR
|
||||
|
||||
if [[ ${1:-} == "-y" ]] || omarchy-update-confirm; then
|
||||
omarchy-snapshot create || (($? == 127))
|
||||
omarchy-update-perform
|
||||
run_update_pipeline
|
||||
fi
|
||||
|
||||
@@ -1,15 +1,119 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Check whether the Omarchy package has an available update.
|
||||
# omarchy:summary=Check whether system or AUR packages have available updates.
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
if pacman -Qu omarchy >/tmp/omarchy-update-available.$$ 2>/dev/null; then
|
||||
cat /tmp/omarchy-update-available.$$
|
||||
rm -f /tmp/omarchy-update-available.$$
|
||||
CHECK_TIMEOUT="${OMARCHY_UPDATE_CHECK_TIMEOUT:-60}"
|
||||
STATE_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/omarchy/updates"
|
||||
TMP_PARENT="${TMPDIR:-/tmp}"
|
||||
|
||||
mkdir -p "$STATE_DIR"
|
||||
|
||||
tmp_dir=$(mktemp -d "$TMP_PARENT/omarchy-update-available.XXXXXX")
|
||||
trap 'rm -rf "$tmp_dir"' EXIT
|
||||
|
||||
packages_raw="$tmp_dir/packages.raw"
|
||||
packages_tmp="$tmp_dir/packages"
|
||||
aur_raw="$tmp_dir/aur.raw"
|
||||
aur_tmp="$tmp_dir/aur"
|
||||
errors_tmp="$tmp_dir/errors"
|
||||
|
||||
packages_file="$STATE_DIR/packages"
|
||||
aur_file="$STATE_DIR/aur"
|
||||
available_file="$STATE_DIR/available"
|
||||
checked_at_file="$STATE_DIR/checked-at"
|
||||
error_file="$STATE_DIR/error"
|
||||
|
||||
: >"$packages_raw"
|
||||
: >"$packages_tmp"
|
||||
: >"$aur_raw"
|
||||
: >"$aur_tmp"
|
||||
: >"$errors_tmp"
|
||||
|
||||
strip_update_output() {
|
||||
local source="$1"
|
||||
local destination="$2"
|
||||
|
||||
sed -E 's/\x1B\[[0-9;]*m//g' "$source" | sed '/^[[:space:]]*$/d' >"$destination"
|
||||
}
|
||||
|
||||
check_system_packages() {
|
||||
local status=0
|
||||
|
||||
if command -v checkupdates >/dev/null 2>&1 && command -v fakeroot >/dev/null 2>&1; then
|
||||
CHECKUPDATES_DB="$tmp_dir/checkupdates-db" timeout "$CHECK_TIMEOUT" checkupdates --nocolor >"$packages_raw" 2>"$tmp_dir/checkupdates.err" || status=$?
|
||||
|
||||
case "$status" in
|
||||
0|2)
|
||||
;;
|
||||
124)
|
||||
echo "System package update check timed out" >>"$errors_tmp"
|
||||
;;
|
||||
*)
|
||||
echo "System package update check failed" >>"$errors_tmp"
|
||||
sed '/^[[:space:]]*$/d' "$tmp_dir/checkupdates.err" >>"$errors_tmp" || true
|
||||
;;
|
||||
esac
|
||||
elif command -v pacman >/dev/null 2>&1; then
|
||||
# Fallback for systems that have not picked up pacman-contrib/fakeroot yet.
|
||||
# This only reports updates already known to the local sync database.
|
||||
pacman -Qu --color never >"$packages_raw" 2>/dev/null || true
|
||||
else
|
||||
echo "pacman is not available" >>"$errors_tmp"
|
||||
fi
|
||||
|
||||
strip_update_output "$packages_raw" "$packages_tmp"
|
||||
}
|
||||
|
||||
check_aur_packages() {
|
||||
local status=0
|
||||
|
||||
command -v pacman >/dev/null 2>&1 || return 0
|
||||
command -v yay >/dev/null 2>&1 || return 0
|
||||
pacman -Qem >/dev/null 2>&1 || return 0
|
||||
|
||||
timeout "$CHECK_TIMEOUT" yay --color never -Qua >"$aur_raw" 2>"$tmp_dir/yay.err" || status=$?
|
||||
|
||||
case "$status" in
|
||||
0|1)
|
||||
;;
|
||||
124)
|
||||
echo "AUR package update check timed out" >>"$errors_tmp"
|
||||
;;
|
||||
*)
|
||||
echo "AUR package update check failed" >>"$errors_tmp"
|
||||
sed '/^[[:space:]]*$/d' "$tmp_dir/yay.err" >>"$errors_tmp" || true
|
||||
;;
|
||||
esac
|
||||
|
||||
strip_update_output "$aur_raw" "$aur_tmp"
|
||||
grep -vw '\[ignored\]$' "$aur_tmp" >"$aur_tmp.filtered" || true
|
||||
mv "$aur_tmp.filtered" "$aur_tmp"
|
||||
}
|
||||
|
||||
check_system_packages
|
||||
check_aur_packages
|
||||
|
||||
cp "$packages_tmp" "$packages_file"
|
||||
cp "$aur_tmp" "$aur_file"
|
||||
cat "$packages_tmp" "$aur_tmp" >"$available_file"
|
||||
date --iso-8601=seconds >"$checked_at_file"
|
||||
|
||||
if [[ -s $errors_tmp ]]; then
|
||||
cp "$errors_tmp" "$error_file"
|
||||
else
|
||||
rm -f "$error_file"
|
||||
fi
|
||||
|
||||
if [[ -s $available_file ]]; then
|
||||
cat "$available_file"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rm -f /tmp/omarchy-update-available.$$
|
||||
echo "Omarchy is up to date"
|
||||
if [[ -s $error_file ]]; then
|
||||
cat "$error_file" >&2
|
||||
fi
|
||||
|
||||
echo "System is up to date"
|
||||
exit 1
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Ensure the status bar icon offering the available update is removed
|
||||
|
||||
omarchy-shell -q SystemUpdate refresh
|
||||
exit 0
|
||||
@@ -1,13 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Remove orphaned system packages after updates
|
||||
# omarchy:summary=Review and optionally remove orphaned system packages after updates
|
||||
# omarchy:requires-sudo=true
|
||||
|
||||
orphans=$(pacman -Qtdq || true)
|
||||
if [[ -n $orphans ]]; then
|
||||
echo -e "\e[32m\nRemove orphan system packages\e[0m"
|
||||
for pkg in $orphans; do
|
||||
sudo pacman -Rs --noconfirm "$pkg" || true
|
||||
done
|
||||
set -e
|
||||
|
||||
mapfile -t orphans < <(pacman -Qtdq 2>/dev/null || true)
|
||||
(( ${#orphans[@]} )) || exit 0
|
||||
|
||||
echo -e "\e[32m\nOrphan system packages\e[0m"
|
||||
printf ' %s\n' "${orphans[@]}"
|
||||
echo
|
||||
|
||||
if [[ ! -t 0 || ! -t 1 ]]; then
|
||||
echo "${#orphans[@]} orphaned package(s) found. Re-run omarchy-update-orphan-pkgs in a terminal to review/remove them."
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! gum confirm --default=false "Remove ${#orphans[@]} orphaned package(s)?"; then
|
||||
echo "Keeping orphaned packages."
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "\e[32m\nRemoving orphan system packages\e[0m"
|
||||
sudo pacman -Rns "${orphans[@]}"
|
||||
echo
|
||||
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/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
|
||||
@@ -1,26 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Run the full Omarchy update pipeline
|
||||
# omarchy:summary=Compatibility wrapper for omarchy-update -y.
|
||||
# omarchy:hidden=true
|
||||
# omarchy:requires-sudo=true
|
||||
|
||||
set -e
|
||||
|
||||
# Ensure screensaver/sleep doesn't set in during updates
|
||||
hyprctl dispatch 'hl.dsp.window.tag({ tag = "+noidle" })' &>/dev/null || hyprctl dispatch tagwindow +noidle &>/dev/null || true
|
||||
|
||||
# Perform all update steps
|
||||
omarchy-update-keyring
|
||||
omarchy-update-available-reset
|
||||
omarchy-update-system-pkgs
|
||||
omarchy-migrate
|
||||
omarchy-update-aur-pkgs
|
||||
omarchy-update-mise
|
||||
omarchy-update-orphan-pkgs
|
||||
omarchy-hook post-update
|
||||
|
||||
omarchy-update-analyze-logs
|
||||
|
||||
omarchy-update-restart
|
||||
|
||||
# Re-enable screensaver/sleep after updates
|
||||
hyprctl dispatch 'hl.dsp.window.tag({ tag = "-noidle" })' &>/dev/null || hyprctl dispatch tagwindow -- -noidle &>/dev/null || true
|
||||
exec omarchy-update -y
|
||||
|
||||
@@ -10,7 +10,7 @@ echo -e "\e[32m\nUpdate system packages\e[0m"
|
||||
# Transition --overwrite: previous script-installed Omarchy wrote these paths
|
||||
# as unowned files; pacman would refuse the omarchy-settings upgrade on first
|
||||
# encounter. Drop each entry once the transition release is the baseline.
|
||||
sudo pacman -Syyu --noconfirm \
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -Syu --noconfirm \
|
||||
--overwrite '/etc/docker/daemon.json' \
|
||||
--overwrite '/etc/gnupg/dirmngr.conf' \
|
||||
--overwrite '/etc/modprobe.d/omarchy-usb-autosuspend.conf' \
|
||||
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Compatibility wrapper for omarchy-migrate-notify.
|
||||
# omarchy:hidden=true
|
||||
|
||||
exec omarchy-migrate-notify "$@"
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=No-op now that omarchy-update-perform is responsible for idle management.
|
||||
# omarchy:hidden=true
|
||||
Reference in New Issue
Block a user