#! /bin/sh set -e umask 002 sub= mkdir -p $HOME$sub : ${REPO=http://guvnor.distorted.org.uk/ftp/pub/mdw} export PATH=/usr/local/bin:$HOME$sub/bin:/usr/bin:/usr/ccs/bin:/bin ### Sort out command line xstuff= false= while [ $# -gt 0 ]; do case "$1" in -x) xstuff=t;; -n) false=false;; --) shift; break;; -*) echo >&2 "$0: bad option"; exit 1;; *) break;; esac shift done ### Find out where I am here=$(pwd) ### Suss out how to print things out=$(echo -n "foo"; echo "bar") if [ "$out" = "foobar" ]; then echon="echo -n" echoc="" else echon="echo" echoc='\c' fi ### Create the necessary directories echo "Creating directories..." for i in bin lib/emacs src; do $echon " $i:$echoc" if [ -d $HOME$sub/$i ]; then echo " already exists." else mkdir -p $HOME$sub/$i echo " done." fi done echo " all done." ### Find out how to fetch things over the net $echon "Finding URL fetcher:$echoc" if curl >/dev/null 2>&1 --version || [ $? -eq 2 ]; then GETURL="curl -fs -o" echo " curl." elif wget >/dev/null 2>&1 --version; then GETURL="wget -q -O" echo " wget." else echo " failed!" echo >&2 "$0: failed to find URL fetcher" exit 1 fi ### Install necessary things echo "Installing useful scripts..." for script in lesspipe.sh start-ssh-agent svnwrap; do $echon " $script:$echoc" found= for p in /bin /usr/bin /usr/local/bin $(echo $PATH | tr : ' '); do if $false [ -x $p/$script ]; then found=t break fi done if [ "$found" ]; then echo " already installed." else $echon " downloading$echoc" $GETURL $HOME$sub/bin/$script $REPO/$script chmod +x $HOME$sub/bin/$script echo " done." fi done echo " all done." ### Install some more complicated programs echo "Installing packages..." systems=" mLib:2.0.3:mLib-config chkpath:1.1.0:tmpdir " [ "$xstuff" ] && systems="$systems mgLib:1.1.0:mgLib-config xtoys:1.3.0:xscsize " for system in $systems; do set -- $(echo $system | tr : ' ') sys=$1 ver=$2 prog=$3 $echon " $sys:$echoc" if $false $prog >/dev/null 2>&1 --version; then echo " already installed." else ( set -e $echon " downloading$echoc" cd $HOME$sub/src rm -rf $sys-$ver.tar.gz $sys-$ver $GETURL $sys-$ver.tar.gz $REPO/$sys-$ver.tar.gz $echon " unpacking$echoc" gzip -cd $sys-$ver.tar.gz | tar xf - $echon " configuring$echoc" cd $sys-$ver mkdir build cd build ../configure --prefix=$HOME$sub >>buildlog 2>&1 $echon " building$echoc" make >>buildlog 2>&1 $echon " installing$echoc" make install >>buildlog 2>&1 echo " done." ) fi done echo " all done." ### Symlink the various dotfiles into place dotfiles=" bash_profile bash_logout bashrc emacs emacs-calc vm mailrc cmucl-init.lisp clisprc.lisp sbclrc dircolors screenrc cvsrc" [ "$xstuff" ] && dotfiles="$dotfiles xinitrc xsession Xdefaults eterm-theme.cfg:.Eterm/themes/Eterm/theme.cfg e-keybindings.cfg:.enlightenment/keybindings.cfg jue-peek.jpg:.enlightenment/backgrounds/jue-peek.jpg" mkdir -p $HOME/test echo "Installing dotfiles..." for d in $dotfiles; do target=.$d case $d in *:*) target=${d#*:} d=${d%%:*};; esac ft=$HOME$sub/$target dir=${ft%/*} mkdir -p $dir ln -s $here/$d $ft.new mv $ft.new $ft echo " $target" done echo " all done." ### Set up the Emacs config echo "Installing Emacs packages..." for elib in make-regexp; do $echon " $elib:$echoc" if $false emacs >/dev/null 2>&1 --batch --eval ' (kill-emacs (condition-case nil (progn (load-library "make-regexp") 0) (error 1)))'; then echo " already installed." else $echon " downloading$echoc" $GETURL $HOME$sub/lib/emacs/make-regexp.el $REPO/make-regexp.el $echon " compiling$echoc" (cd $HOME$sub/lib/emacs; emacs >/dev/null 2>&1 --batch \ --eval '(byte-compile-file "make-regexp.el")') echo " done." fi done echo " all done." $echon "Setting up Emacs configuration:$echoc" $echon " linking$echoc" for link in dot-emacs.el:dot-emacs.el emacs-Makefile:Makefile; do set -- $(echo $link | tr : ' ') from=$1 to=$2 ln -s $here/$from $HOME$sub/lib/emacs/$to.new mv $HOME$sub/lib/emacs/$to.new $HOME$sub/lib/emacs/$to done $echon " compiling$echoc" make >/dev/null 2>&1 -C $HOME$sub/lib/emacs echo " done."