chiark / gitweb /
mdw-conf: Separate out config lookups into its own script.
[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="
8e08f814 71 lesspipe.sh start-ssh-agent svnwrap"
af58d83c 72for script in $scripts; do
f617db13
MW
73 $echon " $script:$echoc"
74 found=
75 for p in /bin /usr/bin /usr/local/bin $(echo $PATH | tr : ' '); do
76 if $false [ -x $p/$script ]; then
77 found=t
78 break
79 fi
80 done
81 if [ "$found" ]; then
82 echo " already installed."
83 else
84 $echon " downloading$echoc"
85 $GETURL $HOME$sub/bin/$script $REPO/$script
86 chmod +x $HOME$sub/bin/$script
87 echo " done."
88 fi
89done
90
852cd5fb 91echo " all done."
f617db13
MW
92
93### Install some more complicated programs
94echo "Installing packages..."
95systems="
8e08f814 96 mlib:2.0.4:crc-mktab
f617db13
MW
97 chkpath:1.1.0:tmpdir
98"
99[ "$xstuff" ] && systems="$systems
8e08f814 100 xtoys:1.4.0:xatom
f617db13
MW
101"
102for system in $systems; do
103 set -- $(echo $system | tr : ' ')
104 sys=$1 ver=$2 prog=$3
105 $echon " $sys:$echoc"
106 if $false $prog >/dev/null 2>&1 --version; then
107 echo " already installed."
108 else
109 ( set -e
110 $echon " downloading$echoc"
111 cd $HOME$sub/src
112 rm -rf $sys-$ver.tar.gz $sys-$ver
113 $GETURL $sys-$ver.tar.gz $REPO/$sys-$ver.tar.gz
114 $echon " unpacking$echoc"
115 gzip -cd $sys-$ver.tar.gz | tar xf -
116 $echon " configuring$echoc"
117 cd $sys-$ver
118 mkdir build
119 cd build
120 ../configure --prefix=$HOME$sub >>buildlog 2>&1
121 $echon " building$echoc"
122 make >>buildlog 2>&1
123 $echon " installing$echoc"
124 make install >>buildlog 2>&1
125 echo " done."
126 )
127 fi
128done
852cd5fb 129echo " all done."
f617db13 130
f141fe0f
MW
131### Install global configuration
132echo -n "Installing dotfile configuration:"
133if [ -f $HOME$sub/.mdw.conf ]; then
134 echo " already installed."
135else
136 cp mdw.conf $HOME$sub/.mdw.conf
137 echo " done."
138fi
139
f617db13 140### Symlink the various dotfiles into place
852cd5fb 141dotfiles="
be7dba95 142 bash_profile bash_logout bashrc inputrc bash_completion
b3468c3b 143 emacs emacs-calc vm
3e3c03ee 144 vimrc mg
b3468c3b 145 mailrc signature
75d08fb2 146 gitconfig cgrc tigrc
e7d23024 147 gdbinit
8a7e906d 148 guile
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
2425eca9 153 dircolors colordiffrc screenrc cvsrc indent.pro"
739bccbf 154[ "$xstuff" ] && dotfiles="$dotfiles
eae29a8c 155 xinitrc xsession Xdefaults vncrc vncsession
1c6b19d4 156 putty-defaults:.putty/sessions/Default%20Settings
739bccbf 157 e-keybindings.cfg:.enlightenment/keybindings.cfg
eae29a8c 158 evnc-keybindings.cfg:.enlightenment-vnc/keybindings.cfg
eebca092
MW
159 e16-bindings:.e16/bindings.cfg
160 e16-config:.e16/e_config--1.0.cfg
161 jue-peek.jpg:.enlightenment/backgrounds/jue-peek.jpg
162 jue-peek.jpg:.e16/backgrounds/jue-peek.jpg"
f617db13
MW
163echo "Installing dotfiles..."
164for d in $dotfiles; do
739bccbf
MW
165 target=.$d
166 case $d in
167 *:*) target=${d#*:} d=${d%%:*};;
168 esac
169 ft=$HOME$sub/$target
170 dir=${ft%/*}
171 mkdir -p $dir
172 ln -s $here/$d $ft.new
173 mv $ft.new $ft
174 echo " $target"
f617db13 175done
852cd5fb 176echo " all done."
f617db13 177
e04c4857
MW
178### Install useful scripts included in this package
179scripts="
547fb8af 180 mdw-editor
b056f5c4 181 mdw-conf
8e08f814 182 movemail-hack
547fb8af 183 emerge-hack"
8e08f814
MW
184[ "$xstuff" ] && scripts="$scripts
185 xrun
186 xshutdown"
e04c4857
MW
187echo "Installing scripts..."
188mkdir -p $HOME$sub/bin
189for s in $scripts; do
190 ft=$HOME$sub/bin/$s
191 ln -s $here/$s $ft.new
192 mv $ft.new $ft
193 echo " $s"
194done
195echo " all done."
196
f617db13 197### Set up the Emacs config
65ff0e8c
MW
198$echon "Finding a suitable emacs:$echoc"
199emacs=no
6960aa99 200for i in emacs22 emacs21 emacs; do
65ff0e8c
MW
201 if type -p >/dev/null $i; then
202 emacs=$i
203 break
204 fi
205done
206if [ $emacs = no ]; then
207 echo " failed."
208 emacs=:
209else
210 echo " $emacs."
211fi
212
f617db13 213echo "Installing Emacs packages..."
400223a1
MW
214emacspkg="
215 make-regexp
1778b496 216 git git-blame vc-git stgit
400223a1
MW
217 quilt"
218for elib in $emacspkg; do
f617db13 219 $echon " $elib:$echoc"
65ff0e8c 220 if $false $emacs >/dev/null 2>&1 --no-site-file --batch --eval '
20eb0692 221 (progn
852cd5fb
MW
222 (setq load-path (nconc load-path (list "~/lib/emacs")))
223 (kill-emacs (condition-case nil
224 (progn (load-library "'"$elib"'") 0)
20eb0692 225 (error 1))))'; then
f617db13
MW
226 echo " already installed."
227 else
228 $echon " downloading$echoc"
20eb0692 229 $GETURL $HOME$sub/lib/emacs/$elib.el $REPO/$elib.el
f617db13
MW
230 $echon " compiling$echoc"
231 (cd $HOME$sub/lib/emacs;
65ff0e8c 232 $emacs >/dev/null 2>&1 --no-site-file --batch \
20eb0692 233 --eval '(byte-compile-file "'"$elib.el"'")')
f617db13
MW
234 echo " done."
235 fi
236done
852cd5fb 237echo " all done."
f617db13
MW
238
239$echon "Setting up Emacs configuration:$echoc"
240$echon " linking$echoc"
241for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do
242 set -- $(echo $link | tr : ' ')
243 from=$1 to=$2
739bccbf
MW
244 ln -s $here/$from $HOME$sub/lib/emacs/$to.new
245 mv $HOME$sub/lib/emacs/$to.new $HOME$sub/lib/emacs/$to
f617db13
MW
246done
247$echon " compiling$echoc"
65ff0e8c 248make >/dev/null 2>&1 -C $HOME$sub/lib/emacs EMACS=$emacs
f617db13 249echo " done."