madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

move mr code repo too
[etc/mrsetup.git] / mrsetup
1 #!/bin/sh
2 #
3 # mrsetup - set up an account using mr
4 #
5 # Copyright © 2008 martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
7 #
8 set -eu
9
10 MY_GIT_SERVER=git.madduck.net
11 MY_GIT_REPOS='srv/git/repos/madduck'
12 MY_ACCOUNT="$(whoami)@$(hostname --fqdn)"
13 MY_ACCOUNT_GIT_REPO=${MY_GIT_REPOS}/accounts/${MY_ACCOUNT}.git
14 MY_GIT_URL_BASE=ssh://$MY_GIT_SERVER
15 MY_MR_REPO_URL=$MY_GIT_URL_BASE/$MY_GIT_REPOS/pub/etc/mr.git
16 MY_ACCOUNT_REPO_URL=$MY_GIT_URL_BASE/$MY_ACCOUNT_GIT_REPO
17 MR_REPO_URL=$MY_GIT_URL_BASE/$MY_GIT_REPOS/pub/code/mr.git
18 MR_CODE=$HOME/code/mr
19 MR_FGIT=.fgits/mr.git
20 MR=.mr
21 BIN_DIR=.bin
22
23 if [ -z "${SSH_AUTH_SOCK:-}" ]; then
24   echo E: '$SSH_AUTH_SOCK' is not set. >&2
25   exit 1
26 fi
27
28 if [ ! -x "$(command -v git)" ]; then
29   echo E: git is not installed. >&2
30   exit 2
31 fi
32
33 cd $HOME
34
35 if [ -e .mrconfig ]; then
36   echo E: .mrconfig already exists. >&2
37   exit 3
38 fi
39
40 if [ -d "$MR_FGIT" ]; then
41   echo E: "$MR_FGIT" already exists. >&2
42   exit 4
43 fi
44
45 if [ -d ".git" ]; then
46   echo E: .git already exists. >&2
47   exit 5
48 fi
49
50 if [ -d code/mr ]; then
51   if [ -x code/mr/mr ]; then
52     echo W: code/mr already exists, let us hope for the best... >&2
53   else
54     echo E: code/mr already exists. >&2
55     exit 6
56   fi
57 else
58   echo I: cloning mr into ${MR_CODE}...
59   mkdir --parent ${MR_CODE%/*}
60   git clone --no-checkout $MR_REPO_URL $MR_CODE
61   (cd $MR_CODE && git checkout -b vcsh origin/vcsh)
62   mkdir --parent $BIN_DIR
63   ln -s ../${MR_CODE}/mr $BIN_DIR/mr
64   echo
65 fi
66
67 cat <<_eof > .mrconfig
68 [DEFAULT]
69 include = cat $MR_CODE/lib/*
70
71 [$MR_FGIT]
72 checkout = git_fake_bare_checkout $MY_MR_REPO_URL ${MR_FGIT##*/} ../../
73 _eof
74 echo I: initial .mrconfig:
75 cat .mrconfig
76 echo
77
78 echo I: cloning mr configuration...
79 $MR_CODE/mr co
80 echo
81
82 echo I: bootstrapping default .mrconfig...
83 cp $MR/templ/.mrconfig .
84
85 echo I: setting up base...
86 $MR_CODE/mr co
87
88 #if ssh $MY_GIT_SERVER "test -d $MY_ACCOUNT_GIT_REPO" </dev/null; then
89 #  echo I: checking out local git repository...
90 #  dir="$(mktemp -d home.XXXXXXXX)"
91 #  trap "rm -rf $dir" 0
92 #  git clone --no-checkout $MY_ACCOUNT_REPO_URL "$dir"/co
93 #  mv "$dir"/co/.git .
94 #  git checkout-index --quiet --index --all
95 #  git reset HEAD
96 #  rm -r $dir
97 #  trap - 0
98 #  echo
99 #else
100 #  echo I: creating remote git repository for this account...
101 #  ssh $MY_GIT_SERVER "
102 #    GIT_DIR=${MY_ACCOUNT_GIT_REPO} git --bare init
103 #    echo 'account setup for $MY_ACCOUNT'
104 #    " </dev/null
105 #  echo I: setting up local git repository...
106 #  git init
107 #  git remote add origin $MY_ACCOUNT_REPO_URL
108 #  git config branch.master.remote origin
109 #  git config branch.master.merge refs/heads/master
110 #  git add .mrconfig
111 #  git commit -m'initial checkin'
112 #  git push --all
113 #  echo
114 #fi
115
116 echo I: spawning a shell...
117 $SHELL -i -l </dev/tty >/dev/tty
118
119 echo I: back from the shell.
120
121 exit 0