diff --git a/scripts/profilers/install/oprofile b/scripts/profilers/install/oprofile index 626325a..e4767de 100755 --- a/scripts/profilers/install/oprofile +++ b/scripts/profilers/install/oprofile @@ -1,397 +1,67 @@ #!/bin/bash -# This is the script to install the oprofile userspace utilities -# +# Install the oprofile userspace utilities. TMP_AUTODIR=`dirname $0` . $TMP_AUTODIR/../../../etc/autobench.conf || . $AUTODIR/scripts/functions -# When upgrading to a new oprofile release, these two variables are the most important -# The oprofile directory in $AUTODIR/sources should match the name below -# This is very important, because the matching oprofile wrapper script needs to use the -# same $OP_VERSION to call the bins, like "$AUTODIR/sources/$OP_VERSION/install/some-biin -OP_VERSION="oprofile-0.9.4-autobench" -# the tar file should also match the name plus .tar.gz -OP_TARFILE=${OP_VERSION}.tar.gz -WEB_LOCATION="http://unc.dl.sourceforge.net/sourceforge/oprofile/$OP_TARFILE" - - -# Do NOT use distro-pkg or distro-sw in this install script, or any -# install script which is commonly used in autobench. Unless you want -# to maintain a repository for every single distro we use and have used, -# on every platform we use or have used, do not do this in common scripts!!! -# -Andrew - -################################################################################ -function exit_err { - echo "There was an error in the previous step. Please correct the problem" - echo "and rerun the script, or complete the steps in the client README" - echo "manually." - exit 2 -} -################################################################################ -function kernel_check { - kernel_version=`uname -r` - - # Used only on RedHat to insatll kernel debug info since Redhat - # likes to be an immense PITA. Only do this if we actually running - # on the distro kernel. - - # we assume if "autoken" is not in the kernel version, this must be a distro kernel - if ! echo $kernel_version | grep autokern >/dev/null; then - if [ -e "/etc/redhat-release" -a ! -f "/boot/vmlinux-$kernel_version" ]; then - vmlinux_path="/usr/lib/debug/lib/modules/$kernel_version/vmlinux" - if [ ! -f "$vmlinux_path" ]; then - echo "Trying to get vmlinux for RedHat with distro-pkg" - distro-pkg kernel-debuginfo - if [ ! -f "$vmlinux_path" ]; then - echo "distro-pkg did not work" - else - echo "symlinking /boot/vmlinux-$kenel_version > $vmlinux_path" - ln -sf "$vmlinux_path" "/boot/vmlinux-$kernel_version" - fi - fi - fi - fi -} - -################################################################################ -# check and install gettext if not found -function gettext_check { - package=gettext-0.17 - tarfile=${package}.tar.gz - echo "Checking for gettext..." - if [ ! -f /usr/lib/libgettextpo.so.0 -a \ - ! -f /usr/lib64/libgettextpo.so.0 ]; then - echo " not found..." - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - /bin/rm -rf $package - if ! tar zxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - pushd $package >/dev/null - echo " configuring..." - if ! ./configure --prefix=/usr >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - exit_err - else - ldconfig - popd >/dev/null - popd >/dev/null - echo " done" - fi - else - echo " found" - fi -} - -################################################################################ -# check and install libiberty if not found in autobench sources -function iberty_check { - package=binutils-2.18 - tarfile=${package}.tar.bz2 - echo "Checking for libiberty in autobench..." - if [ ! -f $AUTODIR/sources/$package/dist/lib/libiberty.a ]; then - echo " not found..." - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - /bin/rm -rf $package - if ! tar jxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - - pushd $package >/dev/null - echo " configuring..." - if ! ./configure --prefix=`pwd`/dist --with-pic >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - exit_err - fi - popd >/dev/null - popd >/dev/null - echo " done" - else - echo " found" - fi - - # make sure we specify to use this new bintuils directory - oprofile_config_opts="$oprofile_config_opts --with-binutils=$AUTODIR/sources/$package/dist" -} -################################################################################ -# check and install popt if not found -function popt_check { - echo "Checking for popt..." - if [ ! -f /usr/lib/libpopt.a ]; then - echo " not found..." - tarfile=popt-1.10.4.tar.gz - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - if ! tar zxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - - dst_dir=`tar ztf $tarfile | head -n 1` - pushd $dst_dir >/dev/null - echo " configuring..." - if ! ./configure --prefix=`pwd`/dist CFLAGS=-m32 LDFLAGS=-m32 >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - exit_err - else - # for some insane reason, popt will always "install" libraries - # in lib64, even if they are 32-bit. Make sure we move the libs - # to the right place - pushd dist >/dev/null - if [ -d lib64 ]; then - /bin/cp lib64/* /usr/lib - else - /bin/cp lib/* /usr/lib - fi - /bin/cp include/* /usr/include - popd >/dev/null - popd >/dev/null - popd >/dev/null - echo " done" - fi - else - echo " found" - fi -} -################################################################################ -# check and install popt-64-bit if not found -function popt64_check { - - # don't bother if we are 32-bit - uname -m | grep i686 >/dev/null && return - - # don't bother if we are ppc64 - uname -m | grep ppc64 >/dev/null && return - - echo "Checking for popt64..." - if [ ! -f /usr/lib64/libpopt.a ]; then - echo " not found..." - tarfile=popt-1.10.4.tar.gz - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - if ! tar zxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - - dst_dir=`tar ztf $tarfile | head -n 1` - pushd $dst_dir >/dev/null - echo " configuring..." - if ! ./configure --prefix=`pwd`/dist CFLAGS=-m64 LDFLAGS=-m64 >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - exit_err - else - pushd dist >/dev/null - /bin/cp lib64/* /usr/lib64 - /bin/cp include/* /usr/include - popd >/dev/null - popd >/dev/null - popd >/dev/null - echo " done" - fi - else - echo " found" - fi -} -################################################################################ -# check and install oprofile if not found -function oprofile_check { - echo "Checking for oprofile..." - if [ ! -f $AUTODIR/sources/$OP_VERSION/dist/bin/opcontrol ]; then - echo " not found..." - tarfile=${OP_VERSION}.tar.gz - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - if ! tar zxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - - dst_dir=`tar ztf $tarfile | head -n 1` - pushd $dst_dir >/dev/null - mkdir -p src - mv * src 2>/dev/null - pushd src >/dev/null - echo " configuring..." - if ! ./configure --prefix=$AUTODIR/sources/$OP_VERSION/dist --with-kernel-support $oprofile_config_opts >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - popd > /dev/null - exit_err - else - popd >/dev/null - popd >/dev/null - popd > /dev/null - echo " done" - fi - else - echo " found" - fi -} - -kernel_check -gettext_check -iberty_check -popt_check -popt64_check -oprofile_check - -oprofileversion=`$AUTODIR/sources/$OP_VERSION/dist/bin/opcontrol --version` -log "$oprofileversion" +# This version must match the version used in $AUTODIR/scripts/profilers/oprofile. +op_version="0.9.4-autobench" + +kernel_version=`uname -r` + +# If we're running on RedHat, install the kernel debug info since Redhat likes +# to be an immense PITA. We assume if "autokern" is not in the kernel version, +# this must be a distro kernel. +if ! echo $kernel_version | grep autokern >/dev/null && + [ -e "/etc/redhat-release" -a ! -f "/boot/vmlinux-$kernel_version" ]; then + vmlinux_path="/usr/lib/debug/lib/modules/$kernel_version/vmlinux" + if [ ! -f "$vmlinux_path" ]; then + log "Trying to get vmlinux for RedHat with distro-pkg" + distro-pkg kernel-debuginfo + if [ ! -f "$vmlinux_path" ]; then + log "distro-pkg did not work" + else + log "symlinking /boot/vmlinux-$kenel_version > $vmlinux_path" + ln -sf "$vmlinux_path" "/boot/vmlinux-$kernel_version" + fi + fi +fi + +# The system-wide version of binutils doesn't always include libiberty, so we +# need to build an autobench-specific version. Additionally, it needs to be +# built with -fPIC. +export CFLAGS="-g -O2 -fPIC" +$AUTODIR/utilities/install/binutils +if [ $? -ne 0 ]; then + log "ERROR installing binutils, which is required for oprofile." + exit 1 +fi +unset CFLAGS + +# Install gettext if the system-wide version is not available. +if [ ! -f /usr/lib/libgettextpo.a -a \ + ! -f /usr/lib64/libgettextpo.a ]; then + $AUTODIR/utilities/install/gettext + if [ $? -ne 0 ]; then + log "ERROR installing gettext, which is required for oprofile." + exit 1 + fi +fi + +# Install popt if the system-wide version is not available. +if [ ! -f /usr/lib/libpopt.a -a \ + ! -f /usr/lib64/libpopt.a ]; then + $AUTODIR/utilities/install/popt + if [ $? -ne 0 ]; then + log "ERROR installing popt, which is required for oprofile." + exit 1 + fi +fi + +$AUTODIR/utilities/install/install-package package=oprofile version=$op_version 'configure_opts=--with-binutils='$AUTODIR'/sources/binutils/dist --with-kernel-support' +if [ $? -ne 0 ]; then + exit 1 +fi + +log "`$AUTODIR/sources/oprofile/dist/bin/opcontrol --version`"