✨ feat(pacman): preserve regional defaults
- ✨ share regional repository generation across install and refresh - 🛡️ reject invalid profiles before replacing configuration Amp-Thread-ID: T-01a0df38-0ea7-759b-bcff-29da223cc567
This commit is contained in:
3 files changed
+57
-6
No files matched your search
Executable
+53
@@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# omarchy:summary=Restore channel and regional pacman defaults in an installed target
|
||||||
|
# omarchy:args=<stable|rc|edge> [target-root]
|
||||||
|
# omarchy:requires-sudo=true
|
||||||
|
# omarchy:hidden=true
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if (( $# < 1 || $# > 2 )); then
|
||||||
|
echo "Usage: omarchy-apply-pacman <stable|rc|edge> [target-root]" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
channel="$1"
|
||||||
|
case "$channel" in
|
||||||
|
stable|rc|edge) ;;
|
||||||
|
*) echo "Invalid pacman channel: $channel" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# The ISO writes this plain-text marker before target finalization. Missing
|
||||||
|
# markers keep existing installations global; never source it as shell code.
|
||||||
|
etc="${2:-/}/etc"
|
||||||
|
region=global
|
||||||
|
if [[ -e $etc/omarchy/region ]]; then
|
||||||
|
region=$(<"$etc/omarchy/region")
|
||||||
|
fi
|
||||||
|
case "$region" in
|
||||||
|
global|cn) ;;
|
||||||
|
*) echo "Unsupported region: $region (expected global or cn)" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Build both files before replacing either. Explicit refreshes retain backups;
|
||||||
|
# ordinary updates do not call this command or enforce regional defaults.
|
||||||
|
staging=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$staging"' EXIT
|
||||||
|
cp "$OMARCHY_PATH/default/pacman/pacman-$channel.conf" "$staging/pacman.conf"
|
||||||
|
cp "$OMARCHY_PATH/default/pacman/mirrorlist-$channel" "$staging/mirrorlist"
|
||||||
|
if [[ $region != "global" ]]; then
|
||||||
|
profile="$OMARCHY_PATH/default/regions/$region/pacman"
|
||||||
|
printf '\n' >> "$staging/pacman.conf"
|
||||||
|
cat "$profile/pacman.conf.append" >> "$staging/pacman.conf"
|
||||||
|
cat "$profile/mirrorlist.append" >> "$staging/mirrorlist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$etc/pacman.d"
|
||||||
|
for file in pacman.conf pacman.d/mirrorlist; do
|
||||||
|
if [[ -e $etc/$file ]]; then
|
||||||
|
cp -f "$etc/$file" "$etc/$file.bak"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
install -m 644 "$staging/pacman.conf" "$etc/pacman.conf"
|
||||||
|
install -m 644 "$staging/mirrorlist" "$etc/pacman.d/mirrorlist"
|
||||||
@@ -30,11 +30,10 @@ if [[ $channel != "stable" && $channel != "rc" && $channel != "edge" ]]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
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"
|
echo "Setting channel to $channel"
|
||||||
sudo cp -f "$OMARCHY_PATH/default/pacman/pacman-$channel.conf" /etc/pacman.conf
|
# Restores the channel templates plus this machine's regional additions, and
|
||||||
sudo cp -f "$OMARCHY_PATH/default/pacman/mirrorlist-$channel" /etc/pacman.d/mirrorlist
|
# backs up both files first. OMARCHY_PATH was verified as this command's root.
|
||||||
|
sudo env "OMARCHY_PATH=$OMARCHY_PATH" "$OMARCHY_PATH/bin/omarchy-apply-pacman" "$channel"
|
||||||
|
|
||||||
# Allow user customization of /etc/pacman.conf before the upgrade runs, so
|
# Allow user customization of /etc/pacman.conf before the upgrade runs, so
|
||||||
# custom repositories and IgnorePkg entries shape the downgrade-capable
|
# custom repositories and IgnorePkg entries shape the downgrade-capable
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# Configure pacman after package installation completes. Offline target package
|
# Configure pacman after package installation completes. Offline target package
|
||||||
# installs use the live ISO's offline pacman.conf until this final restore.
|
# installs use the live ISO's offline pacman.conf until this final restore.
|
||||||
cp -f "$OMARCHY_PATH/default/pacman/pacman-${OMARCHY_MIRROR:-stable}.conf" /etc/pacman.conf
|
"$OMARCHY_PATH/bin/omarchy-apply-pacman" "${OMARCHY_MIRROR:-stable}"
|
||||||
cp -f "$OMARCHY_PATH/default/pacman/mirrorlist-${OMARCHY_MIRROR:-stable}" /etc/pacman.d/mirrorlist
|
|
||||||
|
|
||||||
# Wait for CUPS to own the file, the way omarchy-settings does, so pacman does
|
# Wait for CUPS to own the file, the way omarchy-settings does, so pacman does
|
||||||
# not turn the override into a .pacnew during ISO package installation.
|
# not turn the override into a .pacnew during ISO package installation.
|
||||||
|
|||||||
Reference in new issue
Block a user