chiark / gitweb /
dot-emacs: Add Python `yield' keyword.
[profile] / setup
CommitLineData
f617db13
MW
1#! /bin/sh
2
3set -e
4
5umask 002
6
7sub= up=;
8mkdir -p $HOME$sub
9
10: ${REPO=http://guvnor.distorted.org.uk/ftp/pub/mdw}
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)
29case "$here" in
30 $HOME/*) ;;
31 *) echo >&2 "$0: must be below $HOME"; exit 1;;
32esac
33down=$(echo $here | sed "s#^$HOME/##")
34
35### Suss out how to print things
36out=$(echo -n "foo"; echo "bar")
37if [ "$out" = "foobar" ]; then
38 echon="echo -n"
39 echoc=""
40else
41 echon="echo"
42 echoc='\c'
43fi
44
45### Create the necessary directories
46echo "Creating directories..."
47for i in bin lib/emacs src; do
48 $echon " $i:$echoc"
49 if [ -d $HOME$sub/$i ]; then
50 echo " already exists."
51 else
52 mkdir -p $HOME$sub/$i
53 echo " done."
54 fi
55done
56echo " all done."
57
58### Find out how to fetch things over the net
59$echon "Finding URL fetcher:$echoc"
60if curl >/dev/null 2>&1 --version || [ $? -eq 2 ]; then
61 GETURL="curl -fs -o"
62 echo " curl."
63elif wget >/dev/null 2>&1 --version; then
64 GETURL="wget -q -O"
65 echo " wget."
66else
67 echo " failed!"
68 echo >&2 "$0: failed to find URL fetcher"
69 exit 1
70fi
71
72### Install necessary things
73echo "Installing useful scripts..."
74
ed2a32e1 75for script in lesspipe.sh start-ssh-agent svnwrap; do
f617db13
MW
76 $echon " $script:$echoc"
77 found=
78 for p in /bin /usr/bin /usr/local/bin $(echo $PATH | tr : ' '); do
79 if $false [ -x $p/$script ]; then
80 found=t
81 break
82 fi
83 done
84 if [ "$found" ]; then
85 echo " already installed."
86 else
87 $echon " downloading$echoc"
88 $GETURL $HOME$sub/bin/$script $REPO/$script
89 chmod +x $HOME$sub/bin/$script
90 echo " done."
91 fi
92done
93
94echo " all done."
95
96### Install some more complicated programs
97echo "Installing packages..."
98systems="
99 mLib:2.0.3:mLib-config
100 chkpath:1.1.0:tmpdir
101"
102[ "$xstuff" ] && systems="$systems
103 mgLib:1.1.0:mgLib-config
104 xtoys:1.3.0:xscsize
105"
106for system in $systems; do
107 set -- $(echo $system | tr : ' ')
108 sys=$1 ver=$2 prog=$3
109 $echon " $sys:$echoc"
110 if $false $prog >/dev/null 2>&1 --version; then
111 echo " already installed."
112 else
113 ( set -e
114 $echon " downloading$echoc"
115 cd $HOME$sub/src
116 rm -rf $sys-$ver.tar.gz $sys-$ver
117 $GETURL $sys-$ver.tar.gz $REPO/$sys-$ver.tar.gz
118 $echon " unpacking$echoc"
119 gzip -cd $sys-$ver.tar.gz | tar xf -
120 $echon " configuring$echoc"
121 cd $sys-$ver
122 mkdir build
123 cd build
124 ../configure --prefix=$HOME$sub >>buildlog 2>&1
125 $echon " building$echoc"
126 make >>buildlog 2>&1
127 $echon " installing$echoc"
128 make install >>buildlog 2>&1
129 echo " done."
130 )
131 fi
132done
133echo " all done."
134
135### Symlink the various dotfiles into place
136dotfiles="
137 bash_profile bash_logout bashrc
138 emacs emacs-calc
139 vm mailrc
140 cmucl-init.lisp clisprc.lisp sbclrc
141 dircolors screenrc"
142[ "$xstuff" ] && dotfiles="$dotfiles xinitrc xsession Xdefaults"
143mkdir -p $HOME/test
144echo "Installing dotfiles..."
145for d in $dotfiles; do
146 [ -f $d ]
147 rm -f "$HOME$sub/.$d"
148 ln -s $up$down/$d $HOME$sub/.$d
149 echo " .$d"
150done
151echo " all done."
152
153### Set up the Emacs config
154echo "Installing Emacs packages..."
155for elib in make-regexp; do
156 $echon " $elib:$echoc"
157 if $false emacs >/dev/null 2>&1 --batch --eval '
158 (kill-emacs (condition-case nil
159 (progn (load-library "make-regexp") 0)
160 (error 1)))'; then
161 echo " already installed."
162 else
163 $echon " downloading$echoc"
164 $GETURL $HOME$sub/lib/emacs/make-regexp.el $REPO/make-regexp.el
165 $echon " compiling$echoc"
166 (cd $HOME$sub/lib/emacs;
167 emacs >/dev/null 2>&1 --batch \
168 --eval '(byte-compile-file "make-regexp.el")')
169 echo " done."
170 fi
171done
172echo " all done."
173
174$echon "Setting up Emacs configuration:$echoc"
175$echon " linking$echoc"
176for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do
177 set -- $(echo $link | tr : ' ')
178 from=$1 to=$2
179 rm -f $HOME$sub/lib/emacs/$to
180 ln -s ../../$up$down/$from $HOME$sub/lib/emacs/$to
181done
182$echon " compiling$echoc"
183make >/dev/null 2>&1 -C $HOME$sub/lib/emacs
184echo " done."