From 54850ae619300ca6cf8c53d285205ec179c6852f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 10 Jun 2016 18:54:20 +0100 Subject: [PATCH] New substitute machinery --- infra/substitute | 27 +++++++++++++++++++++++++++ infra/template | 5 +++++ templates/gitconfig.in | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100755 infra/substitute create mode 100644 infra/template create mode 100755 templates/gitconfig.in diff --git a/infra/substitute b/infra/substitute new file mode 100755 index 0000000..112e046 --- /dev/null +++ b/infra/substitute @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +mode_subst () { + $fn >$bfn.new +} + +mode_diff () { + diff -u $dot $bfn.new || test $? = 1 +} + +mode_install () { + mv -f $bfn.new $dot +} + +mode=$1 +case "$mode" in +subst|diff|install) ;; +*) echo >&2 'bad mode'; exit 1; +esac +shift + +for fn in templates/*.in; do + bfn=${fn%.in} + dot=$HOME/.${bfn#*/} + mode_$mode +done diff --git a/infra/template b/infra/template new file mode 100644 index 0000000..6d1dae0 --- /dev/null +++ b/infra/template @@ -0,0 +1,5 @@ +# -*- sh -*- + +cd dot/configs +eval `./checkconfig` +cd ../.. diff --git a/templates/gitconfig.in b/templates/gitconfig.in new file mode 100755 index 0000000..7e874d2 --- /dev/null +++ b/templates/gitconfig.in @@ -0,0 +1,32 @@ +#!/bin/bash +set -e +. infra/template + +case "$(hostname -f)" in +*.xensource.com) + email="ian.jackson@eu.citrix.com" + cache=git://git-cache.xs.citrite.net:9419 + ;; +*) + email=ijackson@chiark.greenend.org.uk + ;; +esac + +cat <