#!/usr/bin/env bash # Installs system-level config that stow can't manage (needs root). set -euo pipefail repo="$(cd "$(dirname "$0")" && pwd)" # pacman: shared [options] snippet sudo install -m644 "$repo/pacman/options.conf" /etc/pacman.d/options.conf # 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. include='Include = /etc/pacman.d/options.conf' tmp="$(mktemp)" awk -v inc="$include" ' $0 == inc { next } seen && !done && /^#?\[/ { print inc; print ""; done = 1 } /^\[options\]/ { seen = 1 } { print } ' /etc/pacman.conf >"$tmp" if ! cmp -s "$tmp" /etc/pacman.conf; then sudo install -m644 "$tmp" /etc/pacman.conf fi rm -f "$tmp"