dotfiles

🎜 Clone'em, tweak'em, stick'em in your $HOME 🎝
git clone https://git.kevinlegouguec.net/dotfiles
Log | Files | Refs | README

commit 0489ee1e567a8a7674fab9b27014b2c3f7383004
parent a797c4ad2da63a3f3eebca309a17ec986cc17357
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Mon,  3 Nov 2025 07:48:38 +0100

Hide current elpa directory behind a symlink

Simplifies rollbacks: revert symlink to previous directory.

Also,

* make directory names more intuitive: use $(date) for the _new_
directory, instead of the old one;
* write update patches to the new directory, instead of the old one;
* tee update summary to the new directory, so that it survives the
transient shell the update was run from.

Also, ask the augurs why 'test' has both -h and -L for symbolic links,

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/test.html

and get no answer 🀷

Diffstat:
M.local/bin/emacs-update-packages | 32++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/.local/bin/emacs-update-packages b/.local/bin/emacs-update-packages @@ -8,7 +8,15 @@ set -euo pipefail test "${DEBUG:-}" && set -x -BKPDIR=.elpa.$(date +%F-%T) +cd ~/.config/emacs + +test -L elpa || { + echo >&2 "'elpa' directory must be a symlink." + exit 1 +} + +OLDELPADIR=$(readlink elpa) +NEWELPADIR=.elpa.$(date +%F-%T) read-packages () { @@ -57,8 +65,8 @@ compare-packages () # Make a patch for later review. ( set +e - diff > ${BKPDIR}/update-${pkg}.patch \ - -ru ${BKPDIR}/${pkg}-${oldv} elpa/${pkg}-${newv} + diff > ${NEWELPADIR}/update-${pkg}.patch \ + -ru ${OLDELPADIR}/${pkg}-${oldv} ${NEWELPADIR}/${pkg}-${newv} diffstatus=$? @@ -73,15 +81,15 @@ compare-packages () done } -( - cd ~/.config/emacs - cp -a elpa ${BKPDIR} +cp -a ${OLDELPADIR} ${NEWELPADIR} + +declare -A OLDPACKAGES NEWPACKAGES - declare -A OLDPACKAGES NEWPACKAGES +read-packages OLDPACKAGES +ln -fsT ${NEWELPADIR} elpa - read-packages OLDPACKAGES - emacs -f package-upgrade-all -f package-autoremove - read-packages NEWPACKAGES +emacs -f package-upgrade-all -f package-autoremove +read-packages NEWPACKAGES - enum-packages | compare-packages | column -ts$'\t' -) +enum-packages | compare-packages | column -ts$'\t' | + tee ${NEWELPADIR}/update.sum