Fix: Make system/install.sh report what it did and stop adding blank lines
Prints whether options.conf and the pacman.conf Include were installed or already in place, then the options pacman ends up using. Dropping an old Include now also drops the blank line written after it, so re-runs leave pacman.conf untouched instead of adding a blank line and rewriting it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,20 +5,35 @@ set -euo pipefail
|
||||
repo="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
# pacman: shared [options] snippet
|
||||
sudo install -m644 "$repo/pacman/options.conf" /etc/pacman.d/options.conf
|
||||
if cmp -s "$repo/pacman/options.conf" /etc/pacman.d/options.conf; then
|
||||
echo "pacman: /etc/pacman.d/options.conf already up to date"
|
||||
else
|
||||
sudo install -m644 "$repo/pacman/options.conf" /etc/pacman.d/options.conf
|
||||
echo "pacman: installed /etc/pacman.d/options.conf"
|
||||
fi
|
||||
|
||||
# The Include goes at the end of [options] (just before the first repo section,
|
||||
# commented or not), so later-wins options like ParallelDownloads override
|
||||
# pacman.conf's own defaults. Any old copy (e.g. straight after [options]) is
|
||||
# removed first, so re-running this also moves it into place.
|
||||
# removed first, along with the blank line written after it, so re-running this
|
||||
# moves it into place without piling up blank lines.
|
||||
include='Include = /etc/pacman.d/options.conf'
|
||||
tmp="$(mktemp)"
|
||||
awk -v inc="$include" '
|
||||
$0 == inc { next }
|
||||
$0 == inc { drop_blank = 1; next }
|
||||
drop_blank && $0 == "" { drop_blank = 0; next }
|
||||
{ drop_blank = 0 }
|
||||
seen && !done && /^#?\[/ { print inc; print ""; done = 1 }
|
||||
/^\[options\]/ { seen = 1 }
|
||||
{ print }
|
||||
' /etc/pacman.conf >"$tmp"
|
||||
if ! cmp -s "$tmp" /etc/pacman.conf; then
|
||||
if cmp -s "$tmp" /etc/pacman.conf; then
|
||||
echo "pacman: /etc/pacman.conf already includes it at the end of [options]"
|
||||
else
|
||||
sudo install -m644 "$tmp" /etc/pacman.conf
|
||||
echo "pacman: added the Include to the end of [options] in /etc/pacman.conf"
|
||||
fi
|
||||
rm -f "$tmp"
|
||||
|
||||
# What pacman actually ends up using
|
||||
echo "pacman: now using: $(pacman-conf Color ILoveCandy VerbosePkgLists ParallelDownloads | paste -sd, - | sed 's/,/, /g')"
|
||||
|
||||
Reference in New Issue
Block a user