Digital housekeeping again: packaging and AI
I have thirty years' worth of accumulated automation material in the form of scripts on my main Linux boxes. Every now and then I do some gardening / housekeeping to try to cut back the growth and organise the material.
Some of my scripts are packaged up. But lots still languish jumbled together in ~/bin.
Indeed I found a script in ~/bin which was literally for evicting executables from ~/bin and sticking them in their own package directory, with an installer and revision control.
Meta
And then it all got a bit meta.
- I used the packager script to evict itself into a new package.
- Then I used it to evict a tool which asks ChatGPT's API a question based on a two-part prompt derived from two separate files (e.g., a prompt that's about the second file)
- And I used *that* to make a tool for autogenerating UNIX man pages for tools
- And then used it to generate its own man page
(etc)
GNU Stow
My package installer uses GNU Stow to do the actual installation; this lets me stick stuff in /usr/local on my own laptop and in ~/.local on shared machines. The installer created by the evict-to-package script looks like this:
set -eu
PKG=$(basename $(realpath $(dirname $0)))
PREFIX=${PREFIX:-/usr/local}
STOW=$PREFIX/stow
DIR=$STOW/$PKG
if [ -d $DIR ]; then
find $DIR -mindepth 1 -maxdepth 1 -exec rm -rf - {} \;
fi
BASE=$(dirname $0)
if [ -d $BASE/bin ]; then
install -d $DIR/bin
install -m 755 -t $DIR/bin bin/*
fi
if [ -d $BASE/man ]; then
# note we're assuming there's only section 1
MANDIR=share/man/man1
install -d $DIR/$MANDIR
install -m 644 -t $DIR/$MANDIR man/*
fi
if [ -d $BASE/share ]; then
# note we're assuming it's all non-executable
install -d $DIR/share
install -m 644 -t $DIR/share share/*
fi
cd $STOW
stow -t $PREFIX $PKG