chiark / gitweb /
dot-emacs: New functions: library-exists-p and maybe-autoload
[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
0633739b 10: ${REPO=http://guvnor.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
51echo " all done."
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
MW
70scripts="
71 lesspipe.sh start-ssh-agent svnwrap"
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
93echo " all done."
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
132echo " all done."
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
MW
143### Symlink the various dotfiles into place
144dotfiles="
917b7a9a 145 bash_profile bash_logout bashrc inputrc
f617db13 146 emacs emacs-calc
a124320a 147 vm mailrc signature
ccaac00b
MW
148 lisp-init.lisp:.cmucl-init.lisp
149 lisp-init.lisp:.sbclrc
150 lisp-init.lisp:.clisprc.lisp
db27ee7d 151 dircolors screenrc cvsrc"
739bccbf
MW
152[ "$xstuff" ] && dotfiles="$dotfiles
153 xinitrc xsession Xdefaults
154 eterm-theme.cfg:.Eterm/themes/Eterm/theme.cfg
155 e-keybindings.cfg:.enlightenment/keybindings.cfg
156 jue-peek.jpg:.enlightenment/backgrounds/jue-peek.jpg"
f617db13
MW
157mkdir -p $HOME/test
158echo "Installing dotfiles..."
159for d in $dotfiles; do
739bccbf
MW
160 target=.$d
161 case $d in
162 *:*) target=${d#*:} d=${d%%:*};;
163 esac
164 ft=$HOME$sub/$target
165 dir=${ft%/*}
166 mkdir -p $dir
167 ln -s $here/$d $ft.new
168 mv $ft.new $ft
169 echo " $target"
f617db13
MW
170done
171echo " all done."
172
173### Set up the Emacs config
65ff0e8c
MW
174$echon "Finding a suitable emacs:$echoc"
175emacs=no
176for i in emacs21 emacs; do
177 if type -p >/dev/null $i; then
178 emacs=$i
179 break
180 fi
181done
182if [ $emacs = no ]; then
183 echo " failed."
184 emacs=:
185else
186 echo " $emacs."
187fi
188
f617db13
MW
189echo "Installing Emacs packages..."
190for elib in make-regexp; do
191 $echon " $elib:$echoc"
65ff0e8c 192 if $false $emacs >/dev/null 2>&1 --no-site-file --batch --eval '
e45ba675 193 (setq load-path (nconc load-path (list "~/lib/emacs")))
f617db13
MW
194 (kill-emacs (condition-case nil
195 (progn (load-library "make-regexp") 0)
196 (error 1)))'; then
197 echo " already installed."
198 else
199 $echon " downloading$echoc"
200 $GETURL $HOME$sub/lib/emacs/make-regexp.el $REPO/make-regexp.el
201 $echon " compiling$echoc"
202 (cd $HOME$sub/lib/emacs;
65ff0e8c 203 $emacs >/dev/null 2>&1 --no-site-file --batch \
f617db13
MW
204 --eval '(byte-compile-file "make-regexp.el")')
205 echo " done."
206 fi
207done
208echo " all done."
209
210$echon "Setting up Emacs configuration:$echoc"
211$echon " linking$echoc"
212for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do
213 set -- $(echo $link | tr : ' ')
214 from=$1 to=$2
739bccbf
MW
215 ln -s $here/$from $HOME$sub/lib/emacs/$to.new
216 mv $HOME$sub/lib/emacs/$to.new $HOME$sub/lib/emacs/$to
f617db13
MW
217done
218$echon " compiling$echoc"
65ff0e8c 219make >/dev/null 2>&1 -C $HOME$sub/lib/emacs EMACS=$emacs
f617db13 220echo " done."