Idempotent Home Directory Setup
When I set up a new FreeBSD jail, I pull my home directory configuration from a GitHub repo. When I initially put this together I didn’t ensure that it was idempotent. Now it is, with the addition of a test and alternation for each operation that is not itself idempotent.
#_# setup.home: Configure the home directory repo for updates
setup.home:
@git remote get-url origin 2>/dev/null || git remote add origin git@github.com:superscript/home.git
@git show-ref --quiet --verify refs/heads/host || git branch -m master host
@git fetch origin
@git show-ref --quiet --verify refs/heads/master || git co -b master origin/master
@git merge --ff
This allows me to use setup.home
as a dependency for the broader setup targets.