Emacs, aspell: Make Emacs use aspell; configure aspell for use.
[profile] / setup
... / ...
CommitLineData
1#! /bin/bash
2
3set -e
4
5###--------------------------------------------------------------------------
6### Basic setup.
7
8umask 002
9
10sub=
11mkdir -p $HOME$sub
12
13: ${REPO=http://ftp.distorted.org.uk/ftp/pub/mdw/profile}
14
15export PATH=/usr/local/bin:$HOME$sub/bin:/usr/bin:/usr/ccs/bin:/bin
16
17###--------------------------------------------------------------------------
18### Sort out command line.
19
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
32###--------------------------------------------------------------------------
33### Environment autoconfiguration.
34
35## Find out where I am
36here=$(pwd)
37
38## Suss out how to print things
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
48## Find out how to fetch things over the net
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
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
80echo "Installing useful scripts..."
81
82scripts="
83 lesspipe.sh start-ssh-agent svnwrap"
84for script in $scripts; do
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
103echo " all done."
104
105###--------------------------------------------------------------------------
106### Install some more complicated programs.
107
108echo "Installing packages..."
109systems="
110 mlib:2.0.4:crc-mktab
111 chkpath:1.1.0:tmpdir
112"
113[ "$xstuff" ] && systems="$systems
114 xtoys:1.4.0:xatom
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
143echo " all done."
144
145###--------------------------------------------------------------------------
146### Install global configuration.
147
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
156## Symlink the various dotfiles into place
157dotfiles="
158 bash_profile bash_logout bashrc inputrc bash_completion
159 emacs emacs-calc vm
160 vimrc mg
161 mailrc signature
162 cgrc tigrc
163 gdbinit
164 guile
165 aspell.conf
166 lisp-init.lisp:.cmucl-init.lisp
167 lisp-init.lisp:.sbclrc
168 lisp-init.lisp:.clisprc.lisp
169 lisp-init.lisp:.eclrc
170 dircolors colordiffrc screenrc cvsrc indent.pro"
171[ "$xstuff" ] && dotfiles="$dotfiles
172 xinitrc xsession Xdefaults vncrc vncsession
173 putty-defaults:.putty/sessions/Default%20Settings
174 eterm-theme.cfg:.Eterm/themes/Eterm/theme.cfg
175 e-keybindings.cfg:.enlightenment/keybindings.cfg
176 evnc-keybindings.cfg:.enlightenment-vnc/keybindings.cfg
177 e16-bindings:.e16/bindings.cfg
178 e16-config:.e16/e_config--1.0.cfg
179 jue-peek.jpg:.enlightenment/backgrounds/jue-peek.jpg
180 jue-peek.jpg:.e16/backgrounds/jue-peek.jpg"
181echo "Installing dotfiles..."
182for d in $dotfiles; do
183 target=.$d
184 case $d in
185 *:*) target=${d#*:} d=${d%%:*};;
186 esac
187 ft=$HOME$sub/$target
188 dir=${ft%/*}
189 mkdir -p $dir
190 ln -s $here/$d $ft.new
191 mv $ft.new $ft
192 echo " $target"
193done
194echo " all done."
195
196###--------------------------------------------------------------------------
197### Process the Git configuration.
198
199echo -n "Installing Git configuration:"
200sed "
2011i\
202### generated by $here/setup; do not edit!\
203
204/@releasekey@/ s::$(./mdw-conf release-key 481334C2):g
205/@gitignore@/ s::$(./mdw-conf gitignore $here/gitignore):g
206" gitconfig >$HOME/.gitconfig.new
207mv $HOME/.gitconfig.new $HOME/.gitconfig
208echo " done."
209
210###--------------------------------------------------------------------------
211### Install useful scripts included in this package.
212
213scripts="
214 mdw-editor
215 mdw-conf
216 movemail-hack
217 emerge-hack"
218[ "$xstuff" ] && scripts="$scripts
219 xrun
220 xshutdown"
221echo "Installing scripts..."
222mkdir -p $HOME$sub/bin
223for s in $scripts; do
224 ft=$HOME$sub/bin/$s
225 ln -s $here/$s $ft.new
226 mv $ft.new $ft
227 echo " $s"
228done
229echo " all done."
230
231###--------------------------------------------------------------------------
232### Set up the Emacs config.
233
234$echon "Finding a suitable emacs:$echoc"
235emacs=no
236for i in emacs22 emacs21 emacs; do
237 if type -p >/dev/null $i; then
238 emacs=$i
239 break
240 fi
241done
242if [ $emacs = no ]; then
243 echo " failed."
244 emacs=:
245else
246 echo " $emacs."
247fi
248
249echo "Installing Emacs packages..."
250emacspkg="
251 make-regexp
252 git git-blame vc-git stgit
253 quilt"
254for elib in $emacspkg; do
255 $echon " $elib:$echoc"
256 if $false $emacs >/dev/null 2>&1 --no-site-file --batch --eval '
257 (progn
258 (setq load-path (nconc load-path (list "~/lib/emacs")))
259 (kill-emacs (condition-case nil
260 (progn (load-library "'"$elib"'") 0)
261 (error 1))))'; then
262 echo " already installed."
263 else
264 $echon " downloading$echoc"
265 $GETURL $HOME$sub/lib/emacs/$elib.el $REPO/$elib.el
266 $echon " compiling$echoc"
267 (cd $HOME$sub/lib/emacs;
268 $emacs >/dev/null 2>&1 --no-site-file --batch \
269 --eval '(byte-compile-file "'"$elib.el"'")')
270 echo " done."
271 fi
272done
273echo " all done."
274
275$echon "Setting up Emacs configuration:$echoc"
276$echon " linking$echoc"
277for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do
278 set -- $(echo $link | tr : ' ')
279 from=$1 to=$2
280 ln -s $here/$from $HOME$sub/lib/emacs/$to.new
281 mv $HOME$sub/lib/emacs/$to.new $HOME$sub/lib/emacs/$to
282done
283$echon " compiling$echoc"
284make >/dev/null 2>&1 -C $HOME$sub/lib/emacs EMACS=$emacs
285echo " done."
286
287###----- That's all, folks --------------------------------------------------