Source

edtk-installer / install-local-edtk+bdb.sh

Full commit
#!/bin/bash -x

BASE=`pwd`
INSTALL_PREFIX=$BASE/installed

PCRE=pcre-7.8
COREDUMPER=coredumper-1.2.1
BDB=db-4.5.20
# Installer Patches

OS=`uname -s`
APPLE=
if [ `uname -s` = Darwin ]; then
  APPLE=true
fi

######### 

function copy_installer_files {
  cp -rp ./install-local-edtk+bdb.sh ./clean.sh ./patches $1
}

function copy_dependencies {
  cp -rp coredumper-1.1.tar.gz db-4.5.20.tar.gz edtk-1.5.1.tar.gz \
         gslsrc20.zip pcre-7.1.tar.bz2 sflsrc21.tgz $1
}

function installer_package {
  IDIR=edtk-installer
  mkdir -p $IDIR
  copy_installer_files $IDIR
  tar cfvjp $IDIR.tar.bz2 $IDIR
  rm -rf $IDIR
}

function full_package {
  PDIR=edtk+bdb+dependencies
  mkdir -p $PDIR
  copy_dependencies $PDIR
  copy_installer_files $PDIR
  tar cfvjp $PDIR.tar.bz2 $PDIR
}

# adding native causes make_release to take around 90 seconds on my 2.8GHz box
case $1 in
  native)   NATIVE=+native                 ;; 
  test)     REGRESSION=1                   ;;
  ipackage) installer_package && exit      ;; 
  fpackage) full_package      && exit      ;;
  help)     echo "$0 [native|test|ipackage|fpackage|help]" && exit ;;
esac

# Downloading, patching, and installing

if [ ! -d edtk-1.5 ]; then
  wget -nc http://www.snookles.com/erlang/edtk/edtk-1.5.1.tar.gz
  tar xfvzp edtk-1.5.1.tar.gz
  pushd edtk-1.5
  cat $BASE/patches/edtk/*.patch |patch -p1
  if [ $APPLE ]; then
    cat $BASE/patches/edtk/apple_specific/*.patch |patch -p1
  fi
  popd
fi

if [ ! -d sfl ]; then 
  wget -nc http://www.imatix.com/pub/sfl/src/sflsrc21.tgz 
  mkdir sfl; pushd sfl 
  tar xfvzp ../sflsrc21.tgz 
  cat $BASE/patches/sfl/*.patch |patch -p0
  chmod a+rx c build 
  export PATH=$PATH:`pwd`
  ./build 
  popd
fi

if [ ! -d gslgen ]; then
  wget -nc http://www.imatix.com/pub/tools/gslsrc20.zip 
  mkdir gslgen; pushd gslgen 
  unzip -a ../gslsrc20.zip 
  cd src 
  cat $BASE/patches/gsl/*.patch |patch -p0
  chmod a+rx c build 
  cp ../../sfl/*.h . 
  cp ../../sfl/*.a . 
  ranlib libsfl.a
  ./build   # it likes it twice
  popd
fi

if [ ! -d $PCRE ]; then
  wget -nc ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/$PCRE.tar.bz2
  tar xfvjp $PCRE.tar.bz2
  pushd $PCRE
  ./configure --prefix=$INSTALL_PREFIX --disable-cpp
  make 2>&1 | tee make.out
  make install 2>&1 | tee make-install.out
  popd
fi

if [ ! $APPLE ] && [ ! -d $COREDUMPER ]; then
  wget -nc http://google-coredumper.googlecode.com/files/$COREDUMPER.tar.gz
  tar xfvzp $COREDUMPER.tar.gz
  pushd $COREDUMPER
  cat $BASE/patches/coredumper/*.patch |patch -p1
  ./configure --prefix=$INSTALL_PREFIX
  make 2>&1 | tee make.out
  make install 2>&1 | tee make-install.out
  popd
fi


if [ ! -d $BDB ]; then
  wget -nc http://download.oracle.com/berkeley-db/$BDB.tar.gz
  tar xfvzp $BDB.tar.gz
  pushd $BDB
  $BASE/edtk-1.5/examples/berkeley_db/patches-to-berkeley-db/db-4.5.20/apply-patches.sh ../edtk-1.5/examples/berkeley_db/patches-to-berkeley-db/db-4.5.20
  cd build_unix
  ../dist/configure --enable-debug --prefix=$INSTALL_PREFIX/BerkeleyDB.4.5
  make
  make install
  popd
fi

if [ -d edtk-1.5 ]; then
  pushd $BASE/edtk-1.5/examples/berkeley_db
#  make_release builds everything and re-builds the erlang modules for release
#  pushd ../../edtk; make clean; make; popd; make clean; make
  pushd releases/
  rm -rf berkeley_db-1.0
  ./make_release.sh berkeley_db-1.0 $NATIVE
  popd 
  if [ $REGRESSION ]; then
    rm regression.out; make regression 2>&1 | tee regression.out
  fi
  popd
fi