#!/bin/bash
# This is the script to install the specJBB2000 benchmark
#

. /etc/autobench.conf || . functions

. $AUTODIR/var/server-repository

# Get Java if it's not installed.
if [ ! \( -d $AUTODIR/sources/IBMJava2 -a -x $AUTODIR/sources/IBMJava2/jre/bin/java \) ]; then
  echo downloading JVM...
  getcommand ibmjava  # The ibmjava install script installs java (IBM's version)
  $AUTODIR/scripts/benchmarks/install/ibmjava
  if [ $? -ne 0 ]; then
    exit 2;
  fi
fi

# Fetch the binary package
pushd $AUTODIR/sources > /dev/null
echo -n downloading SpecJBB tarball...
wget -q $SERVER_REPO/sources/specjbb2000-latest.gz
echo done
if [ $? -ne 0 ]; then 
  echo "Unable to find the specJBB2000 tarball in the repository."
  echo "Please make it available."
  exit 1
fi

# Uncompress it
rm -rf specjbb2000 2> /dev/null
DST_DIR=`tar ztf specjbb2000-latest.gz | head -n 1`
tar zxf specjbb2000-latest.gz
ln -sf $DST_DIR specjbb2000
popd > /dev/null
