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