putty-defaults: Revert bogus change to Putty terminal height.
[profile] / setup
1 #! /bin/bash
2
3 set -e
4
5 umask 002
6
7 sub=
8 mkdir -p $HOME$sub
9
10 : ${REPO=http://ftp.distorted.org.uk/ftp/pub/mdw/profile}
11
12 export PATH=/usr/local/bin:$HOME$sub/bin:/usr/bin:/usr/ccs/bin:/bin
13
14 ### Sort out command line
15 xstuff= false=
16 while [ $# -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
25 done
26
27 ### Find out where I am
28 here=$(pwd)
29
30 ### Suss out how to print things
31 out=$(echo -n "foo"; echo "bar")
32 if [ "$out" = "foobar" ]; then
33 echon="echo -n"
34 echoc=""
35 else
36 echon="echo"
37 echoc='\c'
38 fi
39
40 ### Create the necessary directories
41 echo "Creating directories..."
42 for 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
50 done
51 echo " all done."
52
53 ### Find out how to fetch things over the net
54 $echon "Finding URL fetcher:$echoc"
55 if curl >/dev/null 2>&1 --version || [ $? -eq 2 ]; then
56 GETURL="curl -fs -o"
57 echo " curl."
58 elif wget >/dev/null 2>&1 --version; then
59 GETURL="wget -q -O"
60 echo " wget."
61 else
62 echo " failed!"
63 echo >&2 "$0: failed to find URL fetcher"
64 exit 1
65 fi
66
67 ### Install necessary things
68 echo "Installing useful scripts..."
69
70 scripts="
71 lesspipe.sh start-ssh-agent svnwrap movemail-hack"
72 [ "$xstuff" ] && scripts="$scripts
73 xrun"
74 for script in $scripts; do
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
91 done
92
93 echo " all done."
94
95 ### Install some more complicated programs
96 echo "Installing packages..."
97 systems="
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 "
105 for 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
131 done
132 echo " all done."
133
134 ### Install global configuration
135 echo -n "Installing dotfile configuration:"
136 if [ -f $HOME$sub/.mdw.conf ]; then
137 echo " already installed."
138 else
139 cp mdw.conf $HOME$sub/.mdw.conf
140 echo " done."
141 fi
142
143 ### Symlink the various dotfiles into place
144 dotfiles="
145 bash_profile bash_logout bashrc inputrc bash_completion
146 emacs emacs-calc vm
147 vimrc mg
148 mailrc signature
149 gitconfig cgrc tigrc
150 lisp-init.lisp:.cmucl-init.lisp
151 lisp-init.lisp:.sbclrc
152 lisp-init.lisp:.clisprc.lisp
153 lisp-init.lisp:.eclrc
154 dircolors colordiffrc screenrc cvsrc indent.pro"
155 [ "$xstuff" ] && dotfiles="$dotfiles
156 xinitrc xsession Xdefaults vncrc vncsession
157 putty-defaults:.putty/sessions/Default%20Settings
158 e-keybindings.cfg:.enlightenment/keybindings.cfg
159 evnc-keybindings.cfg:.enlightenment-vnc/keybindings.cfg
160 e16-bindings:.e16/bindings.cfg
161 e16-config:.e16/e_config--1.0.cfg
162 jue-peek.jpg:.enlightenment/backgrounds/jue-peek.jpg
163 jue-peek.jpg:.e16/backgrounds/jue-peek.jpg"
164 echo "Installing dotfiles..."
165 for d in $dotfiles; do
166 target=.$d
167 case $d in
168 *:*) target=${d#*:} d=${d%%:*};;
169 esac
170 ft=$HOME$sub/$target
171 dir=${ft%/*}
172 mkdir -p $dir
173 ln -s $here/$d $ft.new
174 mv $ft.new $ft
175 echo " $target"
176 done
177 echo " all done."
178
179 ### Install useful scripts included in this package
180 scripts="
181 mdw-editor"
182 echo "Installing scripts..."
183 mkdir -p $HOME$sub/bin
184 for s in $scripts; do
185 ft=$HOME$sub/bin/$s
186 ln -s $here/$s $ft.new
187 mv $ft.new $ft
188 echo " $s"
189 done
190 echo " all done."
191
192 ### Set up the Emacs config
193 $echon "Finding a suitable emacs:$echoc"
194 emacs=no
195 for i in emacs21 emacs; do
196 if type -p >/dev/null $i; then
197 emacs=$i
198 break
199 fi
200 done
201 if [ $emacs = no ]; then
202 echo " failed."
203 emacs=:
204 else
205 echo " $emacs."
206 fi
207
208 echo "Installing Emacs packages..."
209 emacspkg="
210 make-regexp
211 git git-blame vc-git stgit
212 quilt"
213 for elib in $emacspkg; do
214 $echon " $elib:$echoc"
215 if $false $emacs >/dev/null 2>&1 --no-site-file --batch --eval '
216 (progn
217 (setq load-path (nconc load-path (list "~/lib/emacs")))
218 (kill-emacs (condition-case nil
219 (progn (load-library "'"$elib"'") 0)
220 (error 1))))'; then
221 echo " already installed."
222 else
223 $echon " downloading$echoc"
224 $GETURL $HOME$sub/lib/emacs/$elib.el $REPO/$elib.el
225 $echon " compiling$echoc"
226 (cd $HOME$sub/lib/emacs;
227 $emacs >/dev/null 2>&1 --no-site-file --batch \
228 --eval '(byte-compile-file "'"$elib.el"'")')
229 echo " done."
230 fi
231 done
232 echo " all done."
233
234 $echon "Setting up Emacs configuration:$echoc"
235 $echon " linking$echoc"
236 for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do
237 set -- $(echo $link | tr : ' ')
238 from=$1 to=$2
239 ln -s $here/$from $HOME$sub/lib/emacs/$to.new
240 mv $HOME$sub/lib/emacs/$to.new $HOME$sub/lib/emacs/$to
241 done
242 $echon " compiling$echoc"
243 make >/dev/null 2>&1 -C $HOME$sub/lib/emacs EMACS=$emacs
244 echo " done."