summaryrefslogtreecommitdiff
path: root/bin/bstraph
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-11-11 23:32:12 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-11-12 11:23:53 -0700
commitf223f38fcab3c94402603d1fadb2d6fa0ac3d05a (patch)
tree8036d67f8e96d335368d8b1ff19d3c98770fd754 /bin/bstraph
parent74585ec4711667c76ecdad7eb53590cb912501ba (diff)
downloaddotfiles-f223f38fcab3c94402603d1fadb2d6fa0ac3d05a.tar.gz
GNU Stow -> hstow, and follow-up tidying & simplifications
Diffstat (limited to 'bin/bstraph')
-rwxr-xr-xbin/bstraph78
1 files changed, 78 insertions, 0 deletions
diff --git a/bin/bstraph b/bin/bstraph
new file mode 100755
index 00000000..7d729ff3
--- /dev/null
+++ b/bin/bstraph
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# Bootstrap home directory after dotfiles repository successfully cloned (see
+# INSINUATE-DOTFILES Consfigurator property and 'insinuate-dotfiles' script).
+# This script should be POSIX sh and idempotent. This is the 'mr fixups'
+# action for src/dotfiles, here rather than in src/dotfiles/lib-src/mr/config
+# so that we can run it even if we don't have a Perl interpreter.
+
+set -e
+
+cd "$HOME/src/dotfiles"
+
+if [ -d /etc/skel ]; then
+ cd /etc/skel
+ for file in $(find . -type f); do
+ [ -e "$HOME/$file" -a ! -h "$HOME/$file" ] \
+ && cmp "$file" "$HOME/$file" >/dev/null && rm "$HOME/$file"
+ done
+ cd "$HOME/src/dotfiles"
+fi
+
+# On Debian systems root gets a special .bashrc and .profile.
+for f in bashrc profile; do
+ [ -e /usr/share/base-files/dot.$f \
+ -a -e "$HOME/.$f" -a ! -h "$HOME/.$f" ] \
+ && cmp /usr/share/base-files/dot.$f "$HOME/.$f" >/dev/null \
+ && rm "$HOME/.$f"
+done
+
+# These will often end up created by, e.g., insinuate-dotfiles.
+# Remove them so that the initial stow will not involve any conflicts.
+for f in gpg.conf gpg-agent.conf dirmngr.conf .gpg-v21-migrated; do
+ [ -h "$HOME/.gnupg/$f" ] || rm -f "$HOME/.gnupg/$f"
+done
+
+bin/hstow stow .
+
+if command -v git >/dev/null; then
+ # Use a rebase workflow as I'm the only committer.
+ git config pull.rebase true
+
+ git config user.signingkey 8DC2487E51ABDD90B5C4753F0F56D0553B6D411B
+
+ # Pushing and pulling are always done explicitly.
+ for branch in $(git for-each-ref \
+ --format='%(refname:short)' refs/heads/); do
+ git rev-parse "$branch"@{upstream} >/dev/null 2>&1 \
+ && git branch --unset-upstream "$branch"
+ done
+ git config push.default nothing
+
+ # This is just for `magit-status'.
+ git config remote.pushDefault origin
+
+ # Don't set up any tracking branches, or fetch it.
+ [ -z "$(git remote)" ] \
+ && git remote add origin https://git.spwhitton.name/dotfiles
+
+ # Non-POSIX cleanup: eventually drop.
+ rm -f .git/hooks/post-checkout{,_01gpgsign}
+ find bin lib/aid lib/backup lib/perl5 lib/hooks lib/athena lib/bins \
+ lib/img lib/mr lib/src local/anacron/spool -type d -empty -delete \
+ 2>/dev/null ||:
+
+ # Eventually move to 'if ! [ "$MR_ACTION" = fixups ]; then' part, above.
+ bin/install-git-hooks dotfiles
+fi
+
+cd "$HOME"
+[ -e .mrconfig ] || cat >.mrconfig <<EOF
+# -*- mode: conf -*-
+
+include = cat ~/src/dotfiles/lib-src/mr/config
+EOF
+mkdir -p .ssh tmp src lib mnt \
+ local/mutt local/big local/pub local/auth \
+ local/src local/bin local/lib local/log local/tmp local/info
+chmod -R u+rwX,go= local/auth