Files
dotfiles/common/bin/pkg-snapshot
T
connor 4d4242f103 Sort package manifests under LC_ALL=C
pkg-snapshot and dots used plain sort, which is locale-dependent: the same
package set ordered differently on two machines, so dots reported drift
that did not exist. A maintenance tool that always cries wolf is the exact
failure mode dots exists to avoid.
2026-09-14 14:47:26 -04:00

21 lines
924 B
Bash
Executable File

#!/usr/bin/env bash
# Record what is installed on this machine, into packages/<hostname>.*
# Run it after installing something worth keeping, then commit the diff.
# The diff doubles as a log of what you added and when.
set -euo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
HOST="${DOTFILES_HOST:-$(hostname | tr '[:upper:]' '[:lower:]')}"
OUT="${REPO}/packages"
mkdir -p "$OUT"
if command -v pacman >/dev/null 2>&1; then
pacman -Qqen | LC_ALL=C sort > "${OUT}/${HOST}.pacman"
pacman -Qqem | LC_ALL=C sort > "${OUT}/${HOST}.aur"
echo "wrote ${HOST}.pacman ($(wc -l < "${OUT}/${HOST}.pacman")) and ${HOST}.aur ($(wc -l < "${OUT}/${HOST}.aur"))"
elif command -v apt-mark >/dev/null 2>&1; then
apt-mark showmanual | LC_ALL=C sort > "${OUT}/${HOST}.apt"
echo "wrote ${HOST}.apt ($(wc -l < "${OUT}/${HOST}.apt"))"
else
echo "pkg-snapshot: no pacman or apt-mark on this machine" >&2; exit 1
fi