#!/bin/bash # # Install script for SystemTap # Builds in $PREFIX/src and installs to $PREFIX P=stap-install ELFUTILS_V=0.141 SYSTEMTAP_V=0.9.8 PREFIX=/opt/stap EXIT_SUCCESS=0 EXIT_FAILURE=-1 # Basic argument parser while [ "$1" != "" ]; do case "$1" in -v) export SYSTEMTAP_V=$2; shift 2;; --systemtap-v) export SYSTEMTAP_V=$2; shift 2;; --elfutils-v) export ELFUTILS_V=$2; shift 2;; *) echo Unrecognised option: $1; shift;; esac done ELFUTILS=elfutils-$ELFUTILS_V.tar.bz2 SYSTEMTAP=systemtap-$SYSTEMTAP_V.tar.gz # Check if SystemTap itself has already been built if [ -e "$PREFIX/bin/stap" ]; then echo SystemTap already installed to $PREFIX exit $EXIT_SUCCESS fi # Make sure path is ok GPP=`which g++` if [ "$GPP" = "" ]; then echo g++ not available exit $EXIT_FAILURE fi if [ "$STAP_PATH" = "" ]; then export STAP_PATH="$PATH" fi # Build SystemTap mkdir -p $PREFIX/src/systemtap-install cd $PREFIX/src/systemtap-install tar -tjf $ELFUTILS 2> /dev/null > /dev/null || rm -f $ELFUTILS tar -tzf $SYSTEMTAP 2> /dev/null > /dev/null || rm -f $SYSTEMTAP # Download elfutils tarball if necessary if [ ! -f $ELFUTILS ]; then TARBALL="https://fedorahosted.org/releases/e/l/elfutils/$ELFUTILS" echo "Downloading sources ($TARBALL) ..." wget -q "$TARBALL" -O "$ELFUTILS" if [ $? -ne 0 ]; then echo "Failed to download from authorative location" exit $EXIT_FAILURE fi fi # Download systemtap tarball if necessary if [ ! -f $SYSTEMTAP ]; then TARBALL="http://sourceware.org/systemtap/ftp/releases/$SYSTEMTAP" echo "Downloading sources ($TARBALL) ..." wget -q "$TARBALL" -O "$SYSTEMTAP" if [ $? -ne 0 ]; then echo "Failed to download from authorative location" exit $EXIT_FAILURE fi fi echo "Deleting old sources ..." rm -rf elfutils-$ELFUTILS_V echo "Extracting sources ..." tar jxf $ELFUTILS tar zxf $SYSTEMTAP echo "Building system tap ..." ( PATH="$STAP_PATH:$PATH" cd systemtap-$SYSTEMTAP_V ./configure --prefix=$PREFIX --with-elfutils=../elfutils-$ELFUTILS_V make || exit $EXIT_FAILURE make install || exit $EXIT_FAILURE ) || exit "$?" exit $EXIT_SUCCESS