Integration only, until omarchy #13690 rebases onto the ARM pacman templates. pacman-templates-test still expects x86 refresh to copy the templates directly.
81 lines
3.4 KiB
Bash
Executable File
81 lines
3.4 KiB
Bash
Executable File
#!/bin/bash -p
|
|
|
|
# omarchy:summary=Overwrite the package configuration for /etc/pacman with the Omarchy default of using its dedicated mirrors and repositories, then update all packages.
|
|
# omarchy:requires-sudo=true
|
|
|
|
if [[ $- != *p* ]]; then
|
|
echo "Refusing an unsafe Bash startup." >&2
|
|
exit 126
|
|
fi
|
|
|
|
security_entrypoint=$(/usr/bin/readlink -e -- "${BASH_SOURCE[0]}") || exit 126
|
|
source "${security_entrypoint%/*}/omarchy-security-functions" || exit 126
|
|
omarchy_security_require_privileged_bash_startup || exit 126
|
|
set -e
|
|
omarchy_security_sanitize_bash_environment "$0" "$@"
|
|
omarchy_security_require_source_root "$0"
|
|
# Channel switching calls this behind its own sanitized PATH and hands the
|
|
# caller's original path over the same way the updater receives it.
|
|
user_path=${OMARCHY_UPDATE_USER_PATH:-$PATH}
|
|
unset OMARCHY_UPDATE_USER_PATH
|
|
# Traps first, so a signal or failure during the entry revocation still
|
|
# exits through the cleanup path.
|
|
omarchy_security_install_sudo_cleanup_traps
|
|
omarchy_security_revoke_sudo_timestamp || exit 1
|
|
omarchy_security_enable_no_update_sudo
|
|
|
|
channel="${1:-}"
|
|
if [[ -n $channel && $channel != "stable" && $channel != "rc" && $channel != "edge" ]]; then
|
|
echo "Invalid channel: $channel" >&2
|
|
exit 2
|
|
fi
|
|
|
|
source "$OMARCHY_PATH/install/helpers/pacman.sh"
|
|
if ! platform=$(omarchy-hw-platform); then
|
|
echo "Cannot tell this machine's platform. No repository configuration changed." >&2
|
|
exit 1
|
|
fi
|
|
templates=$(omarchy_pacman_templates "$platform") || exit 1
|
|
[[ -n $channel ]] || channel=$(omarchy_pacman_default_channel "$platform") || exit 1
|
|
if [[ ! -f $templates/pacman-$channel.conf || ! -f $templates/mirrorlist-$channel ]]; then
|
|
echo "Omarchy has no $channel channel for $platform. No repository configuration changed." >&2
|
|
exit 1
|
|
fi
|
|
|
|
conf=$templates/pacman-$channel.conf mirrorlist=$templates/mirrorlist-$channel
|
|
# Regions render x86 pacman only (omarchy #13690).
|
|
if [[ $platform == x86 ]]; then
|
|
# Render the channel templates plus this machine's regional additions as the
|
|
# caller, so root only copies finished files. The scratch directory goes on
|
|
# every exit, including a failed render, a refused sudo prompt, or a signal;
|
|
# revoking the sudo timestamp stays the last thing the exit path does.
|
|
rendered=$(mktemp -d)
|
|
cleanup_refresh() {
|
|
local status=$?
|
|
rm -rf "$rendered"
|
|
omarchy_security_exit_with_revoked_sudo "$status"
|
|
}
|
|
trap cleanup_refresh EXIT
|
|
"$OMARCHY_PATH/bin/omarchy-apply-pacman" --render "$channel" "$rendered"
|
|
conf=$rendered/pacman.conf mirrorlist=$rendered/mirrorlist
|
|
fi
|
|
|
|
sudo cp -f /etc/pacman.conf /etc/pacman.conf.bak
|
|
sudo cp -f /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
|
|
echo "Setting channel to $channel"
|
|
sudo cp -f "$conf" /etc/pacman.conf
|
|
sudo cp -f "$mirrorlist" /etc/pacman.d/mirrorlist
|
|
|
|
# Allow user customization of /etc/pacman.conf before the upgrade runs, so
|
|
# custom repositories and IgnorePkg entries shape the downgrade-capable
|
|
# transaction below. The hook is user code: it runs cold behind the no-update
|
|
# wrapper, and the timestamp is revoked again afterwards so any authorization
|
|
# the hook obtained for itself cannot carry into the transaction.
|
|
omarchy_security_revoke_sudo_timestamp
|
|
PATH="$OMARCHY_PATH/default/omarchy/sudo-no-update:$user_path" \
|
|
"$OMARCHY_PATH/bin/omarchy-hook" pre-refresh-pacman
|
|
omarchy_security_revoke_sudo_timestamp
|
|
|
|
# Reset all package DBs and then update
|
|
omarchy-update-pacman -Syyuu --noconfirm
|