mdw.conf: Central configuration file for common differences.
[profile] / setup
1 #! /bin/sh
2
3 set -e
4
5 umask 002
6
7 sub=
8 mkdir -p $HOME$sub
9
10 : ${REPO=http://guvnor.distorted.org.uk/ftp/pub/mdw}
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 for script in lesspipe.sh start-ssh-agent svnwrap; do
71 $echon " $script:$echoc"
72 found=
73 for p in /bin /usr/bin /usr/local/bin $(echo $PATH | tr : ' '); do
74 if $false [ -x $p/$script ]; then
75 found=t
76 break
77 fi
78 done
79 if [ "$found" ]; then
80 echo " already installed."
81 else
82 $echon " downloading$echoc"
83 $GETURL $HOME$sub/bin/$script $REPO/$script
84 chmod +x $HOME$sub/bin/$script
85 echo " done."
86 fi
87 done
88
89 echo " all done."
90
91 ### Install some more complicated programs
92 echo "Installing packages..."
93 systems="
94 mLib:2.0.3:mLib-config
95 chkpath:1.1.0:tmpdir
96 "
97 [ "$xstuff" ] && systems="$systems
98 mgLib:1.1.0:mgLib-config
99 xtoys:1.3.0:xscsize
100 "
101 for system in $systems; do
102 set -- $(echo $system | tr : ' ')
103 sys=$1 ver=$2 prog=$3
104 $echon " $sys:$echoc"
105 if $false $prog >/dev/null 2>&1 --version; then
106 echo " already installed."
107 else
108 ( set -e
109 $echon " downloading$echoc"
110 cd $HOME$sub/src
111 rm -rf $sys-$ver.tar.gz $sys-$ver
112 $GETURL $sys-$ver.tar.gz $REPO/$sys-$ver.tar.gz
113 $echon " unpacking$echoc"
114 gzip -cd $sys-$ver.tar.gz | tar xf -
115 $echon " configuring$echoc"
116 cd $sys-$ver
117 mkdir build
118 cd build
119 ../configure --prefix=$HOME$sub >>buildlog 2>&1
120 $echon " building$echoc"
121 make >>buildlog 2>&1
122 $echon " installing$echoc"
123 make install >>buildlog 2>&1
124 echo " done."
125 )
126 fi
127 done
128 echo " all done."
129
130 ### Install global configuration
131 echo -n "Installing dotfile configuration:"
132 if [ -f $HOME$sub/.mdw.conf ]; then
133 echo " already installed."
134 else
135 cp mdw.conf $HOME$sub/.mdw.conf
136 echo " done."
137 fi
138
139 ### Symlink the various dotfiles into place
140 dotfiles="
141 bash_profile bash_logout bashrc
142 emacs emacs-calc
143 vm mailrc
144 lisp-init.lisp:.cmucl-init.lisp
145 lisp-init.lisp:.sbclrc
146 lisp-init.lisp:.clisprc.lisp
147 dircolors screenrc cvsrc"
148 [ "$xstuff" ] && dotfiles="$dotfiles
149 xinitrc xsession Xdefaults
150 eterm-theme.cfg:.Eterm/themes/Eterm/theme.cfg
151 e-keybindings.cfg:.enlightenment/keybindings.cfg
152 jue-peek.jpg:.enlightenment/backgrounds/jue-peek.jpg"
153 mkdir -p $HOME/test
154 echo "Installing dotfiles..."
155 for d in $dotfiles; do
156 target=.$d
157 case $d in
158 *:*) target=${d#*:} d=${d%%:*};;
159 esac
160 ft=$HOME$sub/$target
161 dir=${ft%/*}
162 mkdir -p $dir
163 ln -s $here/$d $ft.new
164 mv $ft.new $ft
165 echo " $target"
166 done
167 echo " all done."
168
169 ### Set up the Emacs config
170 echo "Installing Emacs packages..."
171 for elib in make-regexp; do
172 $echon " $elib:$echoc"
173 if $false emacs >/dev/null 2>&1 --batch --eval '
174 (setq load-path (nconc load-path (list "~/lib/emacs")))
175 (kill-emacs (condition-case nil
176 (progn (load-library "make-regexp") 0)
177 (error 1)))'; then
178 echo " already installed."
179 else
180 $echon " downloading$echoc"
181 $GETURL $HOME$sub/lib/emacs/make-regexp.el $REPO/make-regexp.el
182 $echon " compiling$echoc"
183 (cd $HOME$sub/lib/emacs;
184 emacs >/dev/null 2>&1 --batch \
185 --eval '(byte-compile-file "make-regexp.el")')
186 echo " done."
187 fi
188 done
189 echo " all done."
190
191 $echon "Setting up Emacs configuration:$echoc"
192 $echon " linking$echoc"
193 for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do
194 set -- $(echo $link | tr : ' ')
195 from=$1 to=$2
196 ln -s $here/$from $HOME$sub/lib/emacs/$to.new
197 mv $HOME$sub/lib/emacs/$to.new $HOME$sub/lib/emacs/$to
198 done
199 $echon " compiling$echoc"
200 make >/dev/null 2>&1 -C $HOME$sub/lib/emacs
201 echo " done."