chiark / gitweb /
gitconfig: Provide global ignores, and generate file from skeleton.
[profile] / setup
CommitLineData
65ff0e8c 1#! /bin/bash
f617db13
MW
2
3set -e
4
ce178f96
MW
5###--------------------------------------------------------------------------
6### Basic setup.
7
f617db13
MW
8umask 002
9
4aa875e9 10sub=
f617db13
MW
11mkdir -p $HOME$sub
12
8ba15f37 13: ${REPO=http://ftp.distorted.org.uk/ftp/pub/mdw/profile}
f617db13
MW
14
15export PATH=/usr/local/bin:$HOME$sub/bin:/usr/bin:/usr/ccs/bin:/bin
16
ce178f96
MW
17###--------------------------------------------------------------------------
18### Sort out command line.
19
f617db13
MW
20xstuff= false=
21while [ $# -gt 0 ]; do
22 case "$1" in
23 -x) xstuff=t;;
24 -n) false=false;;
25 --) shift; break;;
26 -*) echo >&2 "$0: bad option"; exit 1;;
27 *) break;;
28 esac
29 shift
30done
31
ce178f96
MW
32###--------------------------------------------------------------------------
33### Environment autoconfiguration.
34
35## Find out where I am
f617db13 36here=$(pwd)
f617db13 37
ce178f96 38## Suss out how to print things
f617db13
MW
39out=$(echo -n "foo"; echo "bar")
40if [ "$out" = "foobar" ]; then
41 echon="echo -n"
42 echoc=""
43else
44 echon="echo"
45 echoc='\c'
46fi
47
ce178f96 48## Find out how to fetch things over the net
f617db13
MW
49$echon "Finding URL fetcher:$echoc"
50if curl >/dev/null 2>&1 --version || [ $? -eq 2 ]; then
51 GETURL="curl -fs -o"
52 echo " curl."
53elif wget >/dev/null 2>&1 --version; then
54 GETURL="wget -q -O"
55 echo " wget."
56else
57 echo " failed!"
58 echo >&2 "$0: failed to find URL fetcher"
59 exit 1
60fi
61
ce178f96
MW
62###--------------------------------------------------------------------------
63### Create the necessary directories.
64
65echo "Creating directories..."
66for i in bin lib/emacs src; do
67 $echon " $i:$echoc"
68 if [ -d $HOME$sub/$i ]; then
69 echo " already exists."
70 else
71 mkdir -p $HOME$sub/$i
72 echo " done."
73 fi
74done
75echo " all done."
76
77###--------------------------------------------------------------------------
78### Install necessary things.
79
f617db13
MW
80echo "Installing useful scripts..."
81
af58d83c 82scripts="
8e08f814 83 lesspipe.sh start-ssh-agent svnwrap"
af58d83c 84for script in $scripts; do
f617db13
MW
85 $echon " $script:$echoc"
86 found=
87 for p in /bin /usr/bin /usr/local/bin $(echo $PATH | tr : ' '); do
88 if $false [ -x $p/$script ]; then
89 found=t
90 break
91 fi
92 done
93 if [ "$found" ]; then
94 echo " already installed."
95 else
96 $echon " downloading$echoc"
97 $GETURL $HOME$sub/bin/$script $REPO/$script
98 chmod +x $HOME$sub/bin/$script
99 echo " done."
100 fi
101done
102
852cd5fb 103echo " all done."
f617db13 104
ce178f96
MW
105###--------------------------------------------------------------------------
106### Install some more complicated programs.
107
f617db13
MW
108echo "Installing packages..."
109systems="
8e08f814 110 mlib:2.0.4:crc-mktab
f617db13
MW
111 chkpath:1.1.0:tmpdir
112"
113[ "$xstuff" ] && systems="$systems
8e08f814 114 xtoys:1.4.0:xatom
f617db13
MW
115"
116for system in $systems; do
117 set -- $(echo $system | tr : ' ')
118 sys=$1 ver=$2 prog=$3
119 $echon " $sys:$echoc"
120 if $false $prog >/dev/null 2>&1 --version; then
121 echo " already installed."
122 else
123 ( set -e
124 $echon " downloading$echoc"
125 cd $HOME$sub/src
126 rm -rf $sys-$ver.tar.gz $sys-$ver
127 $GETURL $sys-$ver.tar.gz $REPO/$sys-$ver.tar.gz
128 $echon " unpacking$echoc"
129 gzip -cd $sys-$ver.tar.gz | tar xf -
130 $echon " configuring$echoc"
131 cd $sys-$ver
132 mkdir build
133 cd build
134 ../configure --prefix=$HOME$sub >>buildlog 2>&1
135 $echon " building$echoc"
136 make >>buildlog 2>&1
137 $echon " installing$echoc"
138 make install >>buildlog 2>&1
139 echo " done."
140 )
141 fi
142done
852cd5fb 143echo " all done."
f617db13 144
ce178f96
MW
145###--------------------------------------------------------------------------
146### Install global configuration.
147
f141fe0f
MW
148echo -n "Installing dotfile configuration:"
149if [ -f $HOME$sub/.mdw.conf ]; then
150 echo " already installed."
151else
152 cp mdw.conf $HOME$sub/.mdw.conf
153 echo " done."
154fi
155
ce178f96 156## Symlink the various dotfiles into place
852cd5fb 157dotfiles="
be7dba95 158 bash_profile bash_logout bashrc inputrc bash_completion
b3468c3b 159 emacs emacs-calc vm
3e3c03ee 160 vimrc mg
b3468c3b 161 mailrc signature
ce178f96 162 cgrc tigrc
e7d23024 163 gdbinit
8a7e906d 164 guile
ccaac00b
MW
165 lisp-init.lisp:.cmucl-init.lisp
166 lisp-init.lisp:.sbclrc
167 lisp-init.lisp:.clisprc.lisp
f6335a0c 168 lisp-init.lisp:.eclrc
2425eca9 169 dircolors colordiffrc screenrc cvsrc indent.pro"
739bccbf 170[ "$xstuff" ] && dotfiles="$dotfiles
eae29a8c 171 xinitrc xsession Xdefaults vncrc vncsession
1c6b19d4 172 putty-defaults:.putty/sessions/Default%20Settings
739bccbf 173 e-keybindings.cfg:.enlightenment/keybindings.cfg
eae29a8c 174 evnc-keybindings.cfg:.enlightenment-vnc/keybindings.cfg
eebca092
MW
175 e16-bindings:.e16/bindings.cfg
176 e16-config:.e16/e_config--1.0.cfg
177 jue-peek.jpg:.enlightenment/backgrounds/jue-peek.jpg
178 jue-peek.jpg:.e16/backgrounds/jue-peek.jpg"
f617db13
MW
179echo "Installing dotfiles..."
180for d in $dotfiles; do
739bccbf
MW
181 target=.$d
182 case $d in
183 *:*) target=${d#*:} d=${d%%:*};;
184 esac
185 ft=$HOME$sub/$target
186 dir=${ft%/*}
187 mkdir -p $dir
188 ln -s $here/$d $ft.new
189 mv $ft.new $ft
190 echo " $target"
f617db13 191done
852cd5fb 192echo " all done."
f617db13 193
ce178f96
MW
194###--------------------------------------------------------------------------
195### Process the Git configuration.
196
197echo -n "Installing Git configuration:"
198sed "
1991i\
200### generated by $(pwd)/setup; do not edit!\
201
202/@releasekey@/ s::$(./mdw-conf release-key 481334C2):g
203/@gitignore@/ s::$(./mdw-conf gitignore $(pwd)/gitignore):g
204" gitconfig >$HOME/.gitconfig.new
205mv $HOME/.gitconfig.new $HOME/.gitconfig
206echo " done."
207
208###--------------------------------------------------------------------------
209### Install useful scripts included in this package.
210
e04c4857 211scripts="
547fb8af 212 mdw-editor
b056f5c4 213 mdw-conf
8e08f814 214 movemail-hack
547fb8af 215 emerge-hack"
8e08f814
MW
216[ "$xstuff" ] && scripts="$scripts
217 xrun
218 xshutdown"
e04c4857
MW
219echo "Installing scripts..."
220mkdir -p $HOME$sub/bin
221for s in $scripts; do
222 ft=$HOME$sub/bin/$s
223 ln -s $here/$s $ft.new
224 mv $ft.new $ft
225 echo " $s"
226done
227echo " all done."
228
ce178f96
MW
229###--------------------------------------------------------------------------
230### Set up the Emacs config.
231
65ff0e8c
MW
232$echon "Finding a suitable emacs:$echoc"
233emacs=no
6960aa99 234for i in emacs22 emacs21 emacs; do
65ff0e8c
MW
235 if type -p >/dev/null $i; then
236 emacs=$i
237 break
238 fi
239done
240if [ $emacs = no ]; then
241 echo " failed."
242 emacs=:
243else
244 echo " $emacs."
245fi
246
f617db13 247echo "Installing Emacs packages..."
400223a1
MW
248emacspkg="
249 make-regexp
1778b496 250 git git-blame vc-git stgit
400223a1
MW
251 quilt"
252for elib in $emacspkg; do
f617db13 253 $echon " $elib:$echoc"
65ff0e8c 254 if $false $emacs >/dev/null 2>&1 --no-site-file --batch --eval '
20eb0692 255 (progn
852cd5fb
MW
256 (setq load-path (nconc load-path (list "~/lib/emacs")))
257 (kill-emacs (condition-case nil
258 (progn (load-library "'"$elib"'") 0)
20eb0692 259 (error 1))))'; then
f617db13
MW
260 echo " already installed."
261 else
262 $echon " downloading$echoc"
20eb0692 263 $GETURL $HOME$sub/lib/emacs/$elib.el $REPO/$elib.el
f617db13
MW
264 $echon " compiling$echoc"
265 (cd $HOME$sub/lib/emacs;
65ff0e8c 266 $emacs >/dev/null 2>&1 --no-site-file --batch \
20eb0692 267 --eval '(byte-compile-file "'"$elib.el"'")')
f617db13
MW
268 echo " done."
269 fi
270done
852cd5fb 271echo " all done."
f617db13
MW
272
273$echon "Setting up Emacs configuration:$echoc"
274$echon " linking$echoc"
275for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do
276 set -- $(echo $link | tr : ' ')
277 from=$1 to=$2
739bccbf
MW
278 ln -s $here/$from $HOME$sub/lib/emacs/$to.new
279 mv $HOME$sub/lib/emacs/$to.new $HOME$sub/lib/emacs/$to
f617db13
MW
280done
281$echon " compiling$echoc"
65ff0e8c 282make >/dev/null 2>&1 -C $HOME$sub/lib/emacs EMACS=$emacs
f617db13 283echo " done."
ce178f96
MW
284
285###----- That's all, folks --------------------------------------------------