chiark / gitweb /
dot/parallel-config: Disable compatibility with moreutils.
[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
82c688c7 13: ${REPO=http://ftp.distorted.org.uk/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
ce178f96
MW
77###--------------------------------------------------------------------------
78### Install some more complicated programs.
79
f617db13
MW
80echo "Installing packages..."
81systems="
285a1386
MW
82 mlib:crc-mktab
83 checkpath:tmpdir
f617db13
MW
84"
85[ "$xstuff" ] && systems="$systems
285a1386 86 xtoys:xatom
f617db13
MW
87"
88for system in $systems; do
89 set -- $(echo $system | tr : ' ')
285a1386 90 sys=$1 prog=$2
f617db13
MW
91 $echon " $sys:$echoc"
92 if $false $prog >/dev/null 2>&1 --version; then
93 echo " already installed."
94 else
95 ( set -e
96 $echon " downloading$echoc"
97 cd $HOME$sub/src
285a1386
MW
98 rm -rf $sys.tar.gz $sys-$ver
99 $GETURL $sys.tar.gz $REPO/$sys.tar.gz
f617db13 100 $echon " unpacking$echoc"
285a1386
MW
101 dir=$(gzip -cd $sys.tar.gz | tar tf - | head -1)
102 gzip -cd $sys.tar.gz | tar xf -
f617db13 103 $echon " configuring$echoc"
285a1386 104 cd $dir
f617db13
MW
105 mkdir build
106 cd build
188ebb31
MW
107 ../configure \
108 --prefix=$HOME$sub \
109 PKG_CONFIG_PATH=$HOME$sub/lib/pkgconfig \
110 >>buildlog 2>&1
f617db13
MW
111 $echon " building$echoc"
112 make >>buildlog 2>&1
113 $echon " installing$echoc"
114 make install >>buildlog 2>&1
115 echo " done."
116 )
117 fi
118done
852cd5fb 119echo " all done."
f617db13 120
ce178f96
MW
121###--------------------------------------------------------------------------
122### Install global configuration.
123
f141fe0f
MW
124echo -n "Installing dotfile configuration:"
125if [ -f $HOME$sub/.mdw.conf ]; then
126 echo " already installed."
127else
128 cp mdw.conf $HOME$sub/.mdw.conf
129 echo " done."
130fi
131
ce178f96 132## Symlink the various dotfiles into place
852cd5fb 133dotfiles="
be7dba95 134 bash_profile bash_logout bashrc inputrc bash_completion
54896c4f 135 emacs emacs-calc vm gnus.el ercrc.el
4fc3203b 136 vimrc mg zile lesskey
bb65ad08 137 parallel-config:.parallel/config
30169591 138 ditz-config
ce39049e 139 mailrc signature muttrc
ce178f96 140 cgrc tigrc
e7d23024 141 gdbinit
8a7e906d 142 guile
1d89ce86 143 rcrc
5d25e440 144 toprc
a6a6806a 145 mc-ini:.mc/ini mc-panels.ini:.mc/panels.ini
f56d38cd 146 pulse-daemon.conf:.pulse/daemon.conf
cbffcf2b 147 aspell.conf
78719982 148 tclshrc:.tclshrc tclshrc:.wishrc
ccaac00b
MW
149 lisp-init.lisp:.cmucl-init.lisp
150 lisp-init.lisp:.sbclrc
151 lisp-init.lisp:.clisprc.lisp
f6335a0c 152 lisp-init.lisp:.eclrc
b5bf3445 153 swank.lisp
5a91acc5 154 mdw-build.conf:.config/mdw-build.conf
3ec64a11 155 w3m-config:.w3m/config elinks.conf:.elinks/elinks.conf
2425eca9 156 dircolors colordiffrc screenrc cvsrc indent.pro"
739bccbf 157[ "$xstuff" ] && dotfiles="$dotfiles
f7cb5c84 158 xinitrc xsession xmodmap vncrc vncsession
5e23020b 159 fonts.conf
e517857c 160 stalonetrayrc
1c6b19d4 161 putty-defaults:.putty/sessions/Default%20Settings
2e60c7f3 162 mdw.session:.config/gnome-session/sessions/mdw.session
7cfa1f1a 163 eterm-theme.cfg:.Eterm/themes/Eterm/theme.cfg
739bccbf 164 e-keybindings.cfg:.enlightenment/keybindings.cfg
eae29a8c 165 evnc-keybindings.cfg:.enlightenment-vnc/keybindings.cfg
f4e43257 166 e16-bindings:.e16/bindings.cfg"
f617db13
MW
167echo "Installing dotfiles..."
168for d in $dotfiles; do
739bccbf
MW
169 target=.$d
170 case $d in
171 *:*) target=${d#*:} d=${d%%:*};;
172 esac
173 ft=$HOME$sub/$target
174 dir=${ft%/*}
175 mkdir -p $dir
99063107 176 ln -s $here/dot/$d $ft.new
739bccbf
MW
177 mv $ft.new $ft
178 echo " $target"
f617db13 179done
852cd5fb 180echo " all done."
f617db13 181
f7cb5c84
MW
182## CPP-hack files which need it.
183cppfiles=""
184[ "$xstuff" ] && cppfiles="$cppfiles
185 Xdefaults"
186echo "Hacking files with C preprocessor..."
187for c in $cppfiles; do
188 target=.$c
189 case $c in
190 *:*) target=${c#*:} c=${c%%:*};;
191 esac
192 ft=$HOME$sub/$target
193 dir=${ft%/*}
194 mkdir -p $dir
18312fb5 195 cpp -P dot/$c -o $ft.new
f7cb5c84
MW
196 mv $ft.new $ft
197 echo " $target"
198done
199echo " all done."
200
403dc178
MW
201## Substitute things which need substituting.
202dotfilessubst="
203 gitconfig
8508a859 204 mykermrc
403dc178
MW
205 pulse-default.pa.in:.pulse/default.pa"
206echo "Installing dotfiles with substitutions..."
207for d in $dotfilessubst; do
208 case $d in
209 *:*) target=${d#*:} d=${d%%:*};;
210 *) target=.$d d=$d.in;;
211 esac
212 ft=$HOME$sub/$target
213 dir=${ft%/*}
214 mkdir -p $dir
215 sed "
2b5d4580
MW
2161i\\
217### generated by $here/setup; do not edit!\\
403dc178
MW
218
219/@home@/ s\a\a$HOME\ag
73165cde 220/@profile@/ s\a\a$here\ag
bf674ae1 221/@releasekey@/ s\a\a$(bin/mdw-conf releasekey 481334C2)\ag
403dc178
MW
222" dot/$d >$ft.new
223 mv $ft.new $ft
224 echo " $target"
225done
226echo " all done."
227
f4e43257 228## Symlink backgrounds.
960af1a5 229backgrounds="
5236501e 230 bsg-supper.jpg
9fe91389 231 harley-quinn.jpg
56c871ef 232 hypatia.jpg
7bdd0453 233 jue-peek.jpg
9f56284f 234 lilith.jpg
7bdd0453
MW
235 lovelace.jpg
236 medusa.jpg
237 noodly.jpg
238 rayne.jpg
239"
f4e43257
MW
240if [ "$xstuff" ]; then
241 echo "Installing backgrounds..."
242 for b in $backgrounds; do
243 for e in enlightenment e16; do
244 dir=$HOME$sub/.$e/backgrounds
245 t=$dir/$b
246 mkdir -p $dir
99063107 247 ln -s $here/bg/$b $t.new
f4e43257
MW
248 mv $t.new $t
249 done
250 echo " $b"
251 done
252 echo " all done."
253fi
254
ce178f96
MW
255###--------------------------------------------------------------------------
256### Install useful scripts included in this package.
257
e04c4857 258scripts="
547fb8af 259 mdw-editor
b20bfd83 260 mdw-pager
b056f5c4 261 mdw-conf
b94830d9 262 mdw-build mdw-sbuild mdw-sbuild-server
5f56828b 263 update-buildable-branch
c4e84cb1 264 emacsclient-hack
8e08f814 265 movemail-hack
aaa2d943 266 sendmail-hack
68b2e9e6 267 aspell-hack
285a1386
MW
268 emerge-hack
269 lesspipe.sh
6a5170a8 270 run-with-shell-env
285a1386 271 start-ssh-agent
6a5170a8 272 start-ssh-pageant
4cdeb0d0 273 svnwrap
73bb9001 274 guest-console
4cdeb0d0 275 hyperspec"
8e08f814 276[ "$xstuff" ] && scripts="$scripts
3bdada49 277 xinitcmd
34a5ea4e 278 un-backslashify-selection
c02999e8 279 lock-screen
b7743290 280 xpra-start-xdummy
8e08f814 281 xshutdown"
e04c4857
MW
282echo "Installing scripts..."
283mkdir -p $HOME$sub/bin
284for s in $scripts; do
285 ft=$HOME$sub/bin/$s
99063107 286 ln -s $here/bin/$s $ft.new
e04c4857
MW
287 mv $ft.new $ft
288 echo " $s"
289done
290echo " all done."
291
4d7d040b
MW
292hacks="
293 ssh:ssh"
294echo "Installing hacks..."
295for h in $hacks; do
296 d=${h%%:*} h=${h#*:}
297 ft=$HOME$sub/bin/hacks/$d
298 mkdir -p $ft
299 ln -s $here/hacks/$h $ft/$h.new
300 mv $ft/$h.new $ft/$h
301 echo " $d:$h"
302done
303echo " all done."
304
ce178f96
MW
305###--------------------------------------------------------------------------
306### Set up the Emacs config.
307
65ff0e8c
MW
308$echon "Finding a suitable emacs:$echoc"
309emacs=no
5fe24792 310for i in emacs22 emacs23 emacs21 emacs; do
65ff0e8c
MW
311 if type -p >/dev/null $i; then
312 emacs=$i
313 break
314 fi
315done
316if [ $emacs = no ]; then
317 echo " failed."
318 emacs=:
319else
320 echo " $emacs."
321fi
322
f617db13 323echo "Installing Emacs packages..."
400223a1
MW
324emacspkg="
325 make-regexp
a1293ade 326 ew-hols
a3bdb4d9 327 mdw-gnus-patch
1778b496 328 git git-blame vc-git stgit
c6fe19d5 329 mdw-multiple-cursors
400223a1
MW
330 quilt"
331for elib in $emacspkg; do
f617db13 332 $echon " $elib:$echoc"
65ff0e8c 333 if $false $emacs >/dev/null 2>&1 --no-site-file --batch --eval '
20eb0692 334 (progn
852cd5fb
MW
335 (setq load-path (nconc load-path (list "~/lib/emacs")))
336 (kill-emacs (condition-case nil
337 (progn (load-library "'"$elib"'") 0)
20eb0692 338 (error 1))))'; then
f617db13
MW
339 echo " already installed."
340 else
99063107
MW
341 if [ -f el/$elib.el ]; then
342 cp el/$elib.el $HOME$sub/lib/emacs/$elib.el
a3bdb4d9
MW
343 else
344 $echon " downloading$echoc"
345 $GETURL $HOME$sub/lib/emacs/$elib.el $REPO/$elib.el
346 fi
f617db13
MW
347 $echon " compiling$echoc"
348 (cd $HOME$sub/lib/emacs;
65ff0e8c 349 $emacs >/dev/null 2>&1 --no-site-file --batch \
20eb0692 350 --eval '(byte-compile-file "'"$elib.el"'")')
f617db13
MW
351 echo " done."
352 fi
353done
852cd5fb 354echo " all done."
f617db13
MW
355
356$echon "Setting up Emacs configuration:$echoc"
357$echon " linking$echoc"
99063107 358for f in dot-emacs.el Makefile; do
f617db13 359 set -- $(echo $link | tr : ' ')
99063107
MW
360 ln -s $here/el/$f $HOME$sub/lib/emacs/$f.new
361 mv $HOME$sub/lib/emacs/$f.new $HOME$sub/lib/emacs/$f
f617db13
MW
362done
363$echon " compiling$echoc"
c39d1139 364{ cd $HOME$sub/lib/emacs && make EMACS=$emacs; } >/dev/null 2>&1
f617db13 365echo " done."
ce178f96
MW
366
367###----- That's all, folks --------------------------------------------------