#!/bin/sh
# --------------------------------------------------------------
# (C) Copyright 2001,2006,
# International Business Machines Corporation,
#
# All Rights Reserved.
# --------------------------------------------------------------
#------------------------------------------------------------------------
# cellsdk
#
# This script installs and integrates the Cell Broadband Engine
# Software Developer Kit (SDK)
#------------------------------------------------------------------------
#
# Version Variables
#
SDK_VERSION=2.1
SDK_BUILD=20070326
PPU_GCC_VERSION=4.1.1-10
PPU_BINUTILS_VERSION=2.17.50-8
PPU_GDB_VERSION=6.6-15
SPU_GCC_VERSION=4.1.1-9
SPU_BINUTILS_VERSION=2.17.50-8
SPU_GDB_VERSION=6.6-12
SPU_NEWLIB_VERSION=1.15.0-7
PPU_SYSROOT_VERSION=fc6-1
CBE_KERNEL_VERSION=2.6.20-CBE
CBE_LIBSPE_VERSION=1.2.2-0
CBE_LIBSPE2_VERSION=2.1.0-0
IBM_XLCPP_VERSION=8.2.0-20
IBM_XLC_VERSION=8.2.0-20
SYSROOT_VERSION=2.1-8
IBM_SYSTEMSIM_VERSION=2.1-10
IBM_SAMPLES_VERSION=2.1-2
IBM_SPU_TIMING_VERSION=2.1-1
IBM_SIMDMATH_VERSION=2.1-1
IBM_ALF_VERSION=2.1-2
OPROFILE_VERSION=0.9.2-0.3
FDPRPRO_VERSION=5.4.0-8_20070226
IBM_MASS_VERSION=4.4.0-20
IBM_CELLPERF_VERSION=2007.03.19-1
IBM_SIMDMAN_VERSION=2.1-1
CBE_LIBSPE2MAN_VERSION=2.1.0-1
#
# Miscellaneous variables
#
LINUX_RELEASE="Fedora Core release 6 (Zod)"
BSC_WEBSITE="http://www.bsc.es/projects/deepcomputing/linuxoncell/cellsimulator/sdk2.1/"
IBM_WEBSITE=http://www.alphaworks.ibm.com/
OPT_DIR=/opt
SCE_INST_DIR=$OPT_DIR/cell/
XLC_INST_DIR=$OPT_DIR/ibmcmp/
BSC_DOWNLOAD_DIR=/tmp/cellsdk-2.1
KERNEL_INSTALLED=0
SDKLOG=$BSC_DOWNLOAD_DIR/cellsdklog
#
# RPMs which must be present on host machine
#
HOST_PREREQS="freeglut freeglut-devel libXmu-devel libXext-devel gcc make perl rsync flex byacc"
IBM_SYSTEMSIM_PREREQS="tk-8.4.* tcl-8.4.*"
#
# Display names of various components
#
SDK_NAME="IBM Cell Broadband Engine SDK"
IBM_SYSTEMSIM_COMP_NAME="IBM Cell System Simulator"
SYSROOT_COMP_NAME="Cell System Simulator System Image"
KERNEL_COMP_NAME="Cell Broadband Engine Kernel"
GNU_TOOLCHAIN_COMP_NAME="GNU Compiler Toolchain"
IBM_SAMPLES_COMP_NAME="IBM Cell Prototype Libraries and Samples"
IBM_SPU_TIMING_COMP_NAME="IBM Cell SPU Timing Utility"
IBM_ALF_COMP_NAME="IBM Cell Accelerator Framework"
OPROFILE_COMP_NAME="Cell OProfile Utility"
FDPRPRO_COMP_NAME="Cell FDPR-PRO Utility"
IBM_XLC_COMP_NAME="IBM XL C/C++ Compilers"
LIBRARY_COMP_NAME="Cell Libraries"
IBM_CELLPERF_COMP_NAME="IBM Cell PerfCounter"
#
# Default install actions for various components
#
KERNEL_INSTALL_ACTION="SKIP"
IBM_SYSTEMSIM_INSTALL_ACTION="SKIP"
SYSROOT_INSTALL_ACTION="SKIP"
GNU_TOOLCHAIN_INSTALL_ACTION="SKIP"
IBM_SAMPLES_INSTALL_ACTION="SKIP"
IBM_SPU_TIMING_INSTALL_ACTION="SKIP"
IBM_ALF_INSTALL_ACTION="SKIP"
OPROFILE_INSTALL_ACTION="SKIP"
FDPRPRO_INSTALL_ACTION="SKIP"
IBM_XLC_INSTALL_ACTION="SKIP"
LIBRARY_INSTALL_ACTION="SKIP"
IBM_CELLPERF_INSTALL_ACTION="SKIP"
#
# Integration variables
#
CBESIM="$CBE_KERNEL_VERSION"
SYSROOT_FILE=/sysroot_disk
SYSROOT_DISK=sysroot_disk
CELL_SDK=cell-sdk
CELL_SDK_INS_DIR=/opt/ibm/$CELL_SDK
CELL_SDK_DIR=/opt/ibm/$CELL_SDK/prototype
CELL_SDK_SYSROOT=$CELL_SDK_DIR/sysroot
MOUNTPT_CELL_SDK_SYSROOT=/mnt/$CELL_SDK-sysroot
SYSTEMSIM_DIR=/opt/ibm/systemsim-cell
SYSTEMSIM_IMAGES_CELL_DIR=$SYSTEMSIM_DIR/images/cell
# This has to come early for the kernel detection to work
CBE_KERNEL_NAME=kernel
CBE_KERNEL=$CBE_KERNEL_NAME-$CBE_KERNEL_VERSION
CBE_KERNEL_RPMS="$CBE_KERNEL.ppc64.rpm"
CBE_KERNEL_ALL_NAMES="$CBE_KERNEL_NAME"
#
# Determine which machine we are installing on
#
CBE=0 # On Cell hardware? Assume no
MACHINE=`uname -m`
if [ "$MACHINE" = "i686" ] ; then
ARCH=i686
ARCH2=i386
ARCH3=i386
elif [ "$MACHINE" = "x86_64" ] ; then
ARCH=i686
ARCH2=i386
ARCH3=x86_64
elif [ "$MACHINE" = "ppc64" ] ; then
ARCH=ppc
ARCH2=ppc
ARCH3=ppc64
grep -q "Cell Broadband Engine" /proc/cpuinfo
if [ $? -eq 0 ] ; then
grep -q "CHRP" /proc/cpuinfo
if [ $? -eq 0 ] ; then
CBE=1
rpm -q $CBE_KERNEL > /dev/null 2>&1
if [ $? = 0 ] ; then
KERNEL_INSTALLED=1
else
KERNEL_INSTALLED=0
fi
fi
fi
else
echo "CELL SDK not supported on this machine type $MACHINE"
exit 1;
fi
#
# On a native platform (PPC64) the actual system root is used whereas
# on a non-native (x86, x86_64) machine the compiler sysroot and
# simulator system root are used instead
# This implies differences in dependencies, directories etc.
#
if [ "$MACHINE" == "ppc64" ] ; then
LIB_SYSROOT_DIR=/
HOST_PREREQS="$HOST_PREREQS netpbm netpbm-devel mesa-libGLU-devel libX11-devel numactl numactl-devel"
RPM_OPTIONS=
else
LIB_SYSROOT_DIR=$SCE_INST_DIR/sysroot
RPM_OPTIONS="--nodeps --noscripts"
fi
#
# BSC_HOST_FILES - are files that will install onto the hosting system.
#
SCE_PPU_BINUTILS_NAME=ppu-binutils
SCE_PPU_BINUTILS=$SCE_PPU_BINUTILS_NAME-$PPU_BINUTILS_VERSION
SCE_PPU_GCC_NAME=ppu-gcc
SCE_PPU_GCC=$SCE_PPU_GCC_NAME-$PPU_GCC_VERSION
SCE_PPU_GDB_NAME=ppu-gdb
SCE_PPU_GDB=$SCE_PPU_GDB_NAME-$PPU_GDB_VERSION
SCE_PPU_CPP_NAME=ppu-gcc-c++
SCE_PPU_CPP=$SCE_PPU_CPP_NAME-$PPU_GCC_VERSION
SCE_PPU_SYSROOT_32_NAME=ppu-sysroot
SCE_PPU_SYSROOT_32=$SCE_PPU_SYSROOT_32_NAME-$PPU_SYSROOT_VERSION
SCE_PPU_SYSROOT_64_NAME=ppu-sysroot64
SCE_PPU_SYSROOT_64=$SCE_PPU_SYSROOT_64_NAME-$PPU_SYSROOT_VERSION
if [ "$ARCH" == "ppc" ] ; then
SCE_PPU_ALL_NAMES="$SCE_PPU_CPP_NAME $SCE_PPU_GDB_NAME $SCE_PPU_GCC_NAME $SCE_PPU_BINUTILS_NAME"
SCE_PPU_ALL="$SCE_PPU_CPP $SCE_PPU_GCC $SCE_PPU_GDB $SCE_PPU_BINUTILS"
SCE_PPU_RPMS="$SCE_PPU_CPP.$ARCH.rpm $SCE_PPU_GCC.$ARCH.rpm $SCE_PPU_GDB.$ARCH.rpm $SCE_PPU_BINUTILS.$ARCH.rpm"
else
SCE_PPU_ALL_NAMES="$SCE_PPU_CPP_NAME $SCE_PPU_GCC_NAME $SCE_PPU_GDB_NAME $SCE_PPU_BINUTILS_NAME $SCE_PPU_SYSROOT_32_NAME $SCE_PPU_SYSROOT_64_NAME"
SCE_PPU_ALL="$SCE_PPU_CPP $SCE_PPU_GCC $SCE_PPU_GDB $SCE_PPU_BINUTILS $SCE_PPU_SYSROOT_32 $SCE_PPU_SYSROOT_64"
SCE_PPU_RPMS="$SCE_PPU_CPP.$ARCH.rpm $SCE_PPU_GCC.$ARCH.rpm $SCE_PPU_GDB.$ARCH.rpm $SCE_PPU_BINUTILS.$ARCH.rpm $SCE_PPU_SYSROOT_32.noarch.rpm $SCE_PPU_SYSROOT_64.noarch.rpm"
fi
SCE_SPU_BINUTILS_NAME=spu-binutils
SCE_SPU_BINUTILS=$SCE_SPU_BINUTILS_NAME-$SPU_BINUTILS_VERSION
SCE_SPU_GCC_NAME=spu-gcc
SCE_SPU_GCC=$SCE_SPU_GCC_NAME-$SPU_GCC_VERSION
SCE_SPU_CPP_NAME=spu-gcc-c++
SCE_SPU_CPP=$SCE_SPU_CPP_NAME-$SPU_GCC_VERSION
SCE_SPU_NEWLIB_NAME=spu-newlib
SCE_SPU_NEWLIB=$SCE_SPU_NEWLIB_NAME-$SPU_NEWLIB_VERSION
SCE_SPU_GDB_NAME=spu-gdb
SCE_SPU_GDB=$SCE_SPU_GDB_NAME-$SPU_GDB_VERSION
SCE_SPU_ALL_NAMES="$SCE_SPU_NEWLIB_NAME $SCE_SPU_CPP_NAME $SCE_SPU_GCC_NAME $SCE_SPU_BINUTILS_NAME $SCE_SPU_GDB_NAME"
SCE_SPU_ALL="$SCE_SPU_NEWLIB $SCE_SPU_CPP $SCE_SPU_GCC $SCE_SPU_BINUTILS $SCE_SPU_GDB"
SCE_SPU_RPMS="$SCE_SPU_NEWLIB.$ARCH.rpm $SCE_SPU_CPP.$ARCH.rpm $SCE_SPU_GCC.$ARCH.rpm $SCE_SPU_BINUTILS.$ARCH.rpm $SCE_SPU_GDB.$ARCH.rpm"
SCE_SPU_PPC_RPMS="$SCE_SPU_NEWLIB.ppc.rpm $SCE_SPU_CPP.ppc.rpm $SCE_SPU_GCC.ppc.rpm $SCE_SPU_BINUTILS.ppc.rpm $SCE_SPU_GDB.ppc.rpm"
CBE_LIBSPE2_NAME=libspe2
CBE_LIBSPE2=$CBE_LIBSPE2_NAME-$CBE_LIBSPE2_VERSION
CBE_LIBSPE2_DEVEL_NAME=libspe2-devel
CBE_LIBSPE2_DEVEL=$CBE_LIBSPE2_DEVEL_NAME-$CBE_LIBSPE2_VERSION
CBE_LIBSPE2MAN_NAME=libspe2man
CBE_LIBSPE2MAN=$CBE_LIBSPE2MAN_NAME-$CBE_LIBSPE2MAN_VERSION
CBE_LIBSPE2MAN_RPMS="$CBE_LIBSPE2MAN.noarch.rpm"
CBE_LIBSPE2MAN_ALL_NAMES="$CBE_LIBSPE2MAN_NAME"
CBE_LIBSPE_NAME=libspe
CBE_LIBSPE=$CBE_LIBSPE_NAME-$CBE_LIBSPE_VERSION
CBE_LIBSPE_DEVEL_NAME=libspe-devel
CBE_LIBSPE_DEVEL=$CBE_LIBSPE_DEVEL_NAME-$CBE_LIBSPE_VERSION
CBE_LIBSPE2_ALL_NAMES="$CBE_LIBSPE2_NAME $CBE_LIBSPE2_DEVEL_NAME $CBE_LIBSPE2MAN_NAME $CBE_LIBSPE_NAME $CBE_LIBSPE_DEVEL_NAME"
CBE_LIBSPE2_ALL="$CBE_LIBSPE2 $CBE_LIBSPE2_DEVEL $CBE_LIBSPE $CBE_LIBSPE_DEVEL"
CBE_LIBSPE2_PPC_RPMS="$CBE_LIBSPE2.ppc.rpm $CBE_LIBSPE2_DEVEL.ppc.rpm $CBE_LIBSPE.ppc.rpm $CBE_LIBSPE_DEVEL.ppc.rpm"
CBE_LIBSPE2_PPC64_RPMS="$CBE_LIBSPE2.ppc64.rpm $CBE_LIBSPE2_DEVEL.ppc64.rpm $CBE_LIBSPE.ppc64.rpm $CBE_LIBSPE_DEVEL.ppc64.rpm"
CBE_ELFSPE2_NAME=elfspe2
CBE_ELFSPE2=$CBE_ELFSPE2_NAME-$CBE_LIBSPE2_VERSION
# only install ELFSPE on Cell machines
if (( CBE )) ; then
CBE_LIBSPE2_ALL_NAMES="$CBE_LIBSPE2_ALL_NAMES $CBE_ELFSPE2_NAME"
CBE_LIBSPE2_ALL="$CBE_LIBSPE2_ALL $CBE_ELFSPE2"
CBE_LIBSPE2_PPC_RPMS="$CBE_LIBSPE2_PPC_RPMS $CBE_ELFSPE2.ppc.rpm"
fi
SYSROOT_NAME=sysroot_image
SYSROOT=$SYSROOT_NAME-$SYSROOT_VERSION
SYSROOT_RPMS="$SYSROOT.noarch.rpm"
SYSROOT_ALL_NAMES="$SYSROOT_NAME"
OPROFILE_NAME=oprofile
OPROFILE=$OPROFILE_NAME-$OPROFILE_VERSION
OPROFILE_RPMS="$OPROFILE.ppc.rpm"
OPROFILE_ALL_NAMES="$OPROFILE_NAME"
FDPRPRO_NAME=fdprpro
FDPRPRO=$FDPRPRO_NAME-$FDPRPRO_VERSION
FDPRPRO_RPMS="$FDPRPRO.ppc.rpm"
FDPRPRO_ALL_NAMES="$FDPRPRO_NAME"
EXTRA_PATH=/opt/ibm/sysroot-extra
EXTRA_CROSS_LIBS="netpbm netpbm-devel numactl numactl-devel"
EXTRA_CROSS_LIBS_RPMS="$EXTRA_PATH/netpbm-10.35-6.fc6.ppc.rpm $EXTRA_PATH/netpbm-devel-10.35-6.fc6.ppc.rpm $EXTRA_PATH/numactl-0.9.8-1.35.ppc.rpm $EXTRA_PATH/numactl-devel-0.9.8-1.35.ppc.rpm"
#
# The following packages are not currently installed by this script
#
OPROFILE_DEBUGINFO_NAME=oprofile-debuginfo
OPROFILE_DEBUGINFO=$OPROFILE_DEBUGINFO_NAME-$OPROFILE_VERSION
OPROFILE_DEBUGINFO_RPMS="$OPROFILE_DEBUGINFO.ppc.rpm"
#
# IBM_HOST_FILES - are files that will install onto the hosting system.
#
IBM_XLC_CMP_NAME=xlc.cmp
IBM_XLC_CMP=$IBM_XLC_CMP_NAME-$IBM_XLC_VERSION
IBM_XLC_LIB_NAME=xlc.lib
IBM_XLC_LIB=$IBM_XLC_LIB_NAME-$IBM_XLC_VERSION
IBM_XLCPP_CMP_NAME=xlcpp.cmp
IBM_XLCPP_CMP=$IBM_XLCPP_CMP_NAME-$IBM_XLCPP_VERSION
IBM_XLCPP_LIB_NAME=xlcpp.lib
IBM_XLCPP_LIB=$IBM_XLCPP_LIB_NAME-$IBM_XLCPP_VERSION
IBM_XLCPP_HELP_NAME=xlcpp.help
IBM_XLCPP_HELP=$IBM_XLCPP_HELP_NAME-$IBM_XLCPP_VERSION
if [ "$ARCH" == "ppc" ] ; then
IBM_XLC_RPMS="$IBM_XLC_LIB.$ARCH3.rpm $IBM_XLC_CMP.$ARCH3.rpm $IBM_XLCPP_LIB.$ARCH3.rpm $IBM_XLCPP_CMP.$ARCH3.rpm $IBM_XLCPP_HELP.$ARCH3.rpm"
IBM_XLC_ALL_NAMES="$IBM_XLC_CMP_NAME $IBM_XLC_LIB_NAME $IBM_XLCPP_CMP_NAME $IBM_XLCPP_LIB_NAME $IBM_XLCPP_HELP_NAME"
else
IBM_XLC_RPMS="$IBM_XLC_LIB.$ARCH2.rpm $IBM_XLC_CMP.$ARCH2.rpm $IBM_XLCPP_LIB.$ARCH2.rpm $IBM_XLCPP_CMP.$ARCH2.rpm $IBM_XLCPP_HELP.$ARCH2.rpm"
IBM_XLC_ALL_NAMES="$IBM_XLC_CMP_NAME $IBM_XLC_LIB_NAME $IBM_XLCPP_CMP_NAME $IBM_XLCPP_LIB_NAME $IBM_XLCPP_HELP_NAME"
fi
IBM_SYSTEMSIM_NAME=systemsim-cell
IBM_SYSTEMSIM=$IBM_SYSTEMSIM_NAME-$IBM_SYSTEMSIM_VERSION
IBM_SYSTEMSIM_RPMS="$IBM_SYSTEMSIM.$ARCH3.rpm"
IBM_SYSTEMSIM_ALL_NAMES="$IBM_SYSTEMSIM_NAME"
IBM_SAMPLES_NAME=cell-sdk-lib-samples
IBM_SAMPLES=$IBM_SAMPLES_NAME-$IBM_SAMPLES_VERSION
IBM_SAMPLES_RPMS="$IBM_SAMPLES.noarch.rpm"
IBM_SAMPLES_ALL_NAMES="$IBM_SAMPLES_NAME"
IBM_SPU_TIMING_NAME=cell-spu-timing
IBM_SPU_TIMING=$IBM_SPU_TIMING_NAME-$IBM_SPU_TIMING_VERSION
IBM_SPU_TIMING_RPMS="$IBM_SPU_TIMING.$ARCH.rpm"
IBM_SPU_TIMING_ALL_NAMES="$IBM_SPU_TIMING_NAME"
IBM_SIMDMATH_NAME=simdmath
IBM_SIMDMATH=$IBM_SIMDMATH_NAME-$IBM_SIMDMATH_VERSION
IBM_SIMDMATH_RPMS="$IBM_SIMDMATH.ppc.rpm"
IBM_SIMDMATH_ALL_NAMES="$IBM_SIMDMATH_NAME"
IBM_SPU_SIMDMATH_NAME=spu-simdmath
IBM_SPU_SIMDMATH=$IBM_SPU_SIMDMATH_NAME-$IBM_SIMDMATH_VERSION
IBM_SPU_SIMDMATH_RPMS="$IBM_SPU_SIMDMATH.ppc.rpm"
IBM_SPU_SIMDMATH_ALL_NAMES="$IBM_SPU_SIMDMATH_NAME"
IBM_SIMDMAN_NAME=simdman
IBM_SIMDMAN=$IBM_SIMDMAN_NAME-$IBM_SIMDMAN_VERSION
IBM_SIMDMAN_RPMS="$IBM_SIMDMAN.noarch.rpm"
IBM_SIMDMAN_ALL_NAMES="$IBM_SIMDMAN_NAME"
IBM_ALF_NAME=cell-alf
IBM_ALF=$IBM_ALF_NAME-$IBM_ALF_VERSION
IBM_ALF_RPMS="$IBM_ALF.noarch.rpm"
IBM_ALF_ALL_NAMES="$IBM_ALF_NAME"
IBM_CELLPERF_TOOL_NAME=cellperfctr-tools
IBM_CELLPERF_TOOL=$IBM_CELLPERF_TOOL_NAME-$IBM_CELLPERF_VERSION
IBM_CELLPERF_DRIVER_NAME=cellperfctr-driver
IBM_CELLPERF_DRIVER=$IBM_CELLPERF_DRIVER_NAME-$IBM_CELLPERF_VERSION
IBM_CELLPERF_RPMS="$IBM_CELLPERF_TOOL.ppc64.rpm $IBM_CELLPERF_DRIVER.ppc64.rpm"
IBM_CELLPERF_ALL_NAMES="$IBM_CELLPERF_TOOL_NAME $IBM_CELLPERF_DRIVER_NAME"
IBM_SPU_MASS_NAME=spu-mass.lib
IBM_SPU_MASS=$IBM_SPU_MASS_NAME-$IBM_MASS_VERSION
IBM_PPU_MASS_NAME=ppu-mass.lib
IBM_PPU_MASS=$IBM_PPU_MASS_NAME-$IBM_MASS_VERSION
IBM_PPU_MASS64_NAME=ppu-mass.lib
IBM_PPU_MASS64=$IBM_PPU_MASS64_NAME-$IBM_MASS_VERSION
IBM_MASS_RPMS="$IBM_PPU_MASS.ppc.rpm $IBM_SPU_MASS.ppc.rpm"
IBM_MASS64_RPMS="$IBM_PPU_MASS64.ppc64.rpm"
IBM_MASS_ALL_NAMES="$IBM_PPU_MASS_NAME $IBM_SPU_MASS_NAME"
#
# group PPU and SPU libraries into one variable for ease of install
# and uninstall
#
LIBRARY_PPC_RPMS="$CBE_LIBSPE2_PPC_RPMS $CBE_LIBSPE2MAN_RPMS $IBM_SIMDMATH_RPMS $IBM_SIMDMAN_RPMS $IBM_MASS_RPMS $IBM_SPU_SIMDMATH_RPMS"
LIBRARY_PPC64_RPMS="$CBE_LIBSPE2_PPC64_RPMS $IBM_MASS64_RPMS"
LIBRARY_ALL_NAMES="$CBE_LIBSPE2_ALL_NAMES $CBE_LIBSPE2MAN_ALL_NAMES $IBM_SIMDMATH_ALL_NAMES $IBM_SIMDMAN_ALL_NAMES $IBM_MASS_ALL_NAMES $IBM_SPU_SIMDMATH_ALL_NAMES"
#--------------------------------------------------------------------------
# Determines what RPMs from the BSC site are required for the requested
# operation
#
# args:
# <none>
#
# return:
# 0 =
function determine_bsc_rpms()
{
echo "--Entering Determine the Barcelona RPMs" >> $SDKLOG
BSC_HOST_FILES="$BSC_HOST_FILES $SCE_PPU_RPMS $SCE_SPU_PPC_RPMS"
BSC_HOST_FILES="$BSC_HOST_FILES $CBE_LIBSPE2_PPC_RPMS $CBE_LIBSPE2_PPC64_RPMS $CBE_LIBSPE_PPC_RPMS $CBE_LIBSPE_PPC64_RPMS"
if [ "$ARCH" != "ppc" ] ; then
BSC_HOST_FILES="$BSC_HOST_FILES $SCE_SPU_RPMS"
fi
if (( CBE )) ; then
BSC_HOST_FILES="$BSC_HOST_FILES $OPROFILE_RPMS $CBE_KERNEL_RPMS $IBM_CELLPERF_RPMS"
fi
if ! (( OPT_NO_SIM )) ; then
BSC_HOST_FILES="$BSC_HOST_FILES $SYSROOT_RPMS"
fi
echo "--Exiting Determine the Barcelona RPMs " >> $SDKLOG
}
#--------------------------------------------------------------------------
# Determines what RPMs from the IBM alphaWorks site are required for the
# requested operation
#
# args:
# <none>
#
# return:
# 0 =
function determine_alphaworks_rpms()
{
echo "--Entering determine the alphaWorks RPMs" >> $SDKLOG
IBM_HOST_FILES="$IBM_SAMPLES_RPMS $IBM_SPU_TIMING_RPMS $IBM_SIMDMATH_RPMS $IBM_SPU_SIMDMATH_RPMS $IBM_ALF_RPMS $IBM_XLC_RPMS $IBM_PPU_RPMS $IBM_MASS64_RPMS"
if [ "$ARCH" != "ppc" ] ; then
IBM_HOST_FILES="$IBM_HOST_FILES"
fi
if [ "$ARCH" == "ppc" ] ; then
IBM_HOST_FILES="$IBM_HOST_FILES $FDPRPRO_RPMS"
fi
if ! (( OPT_NO_SIM )) ; then
IBM_HOST_FILES="$IBM_HOST_FILES $IBM_SYSTEMSIM_RPMS"
fi
echo "--Exit determine the alphaWorks RPMs" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Checks if the CBE Kernel is installed, and if not, prompts for installation.
# This method should only be called on CBE hardware.
#
# args:
# <none>
#
# return:
# 0 =
function CBE_check_for_kernel()
{
echo "--Entering CBE check for kernel" >> $SDKLOG
# Determine if the kernel should be installed
if (( OPT_NO_KERNEL)) ; then
if ! (( KERNEL_INSTALLED )) ; then
echo " Functions of the SDK will not operate properly "
echo " without the CBE Enhanced kernel. Please re-run"
echo " the installation and select the CBE Enhanced kernel"
echo ""
exit 1
fi
fi
if ! (( OPT_NO_KERNEL)) ; then
if ! (( KERNEL_INSTALLED )) ; then
echo ""
echo "WARNING: The $KERNEL_COMP_NAME is not installed."
echo " Some functions of the SDK will not operate properly "
echo " without the CBE Enhanced kernel."
echo ""
echo "--CBE Kernel not installed" >> $SDKLOG
local msg=""
if [ "$TASK" = "depend" ] ; then
msg="Do you plan to install the Cell SDK 2.1 enhanced kernel?"
else
msg="Install the Cell SDK 2.1 enhanced kernel?"
fi
prompt_yes_no "$msg"
if [ $? = 0 ] ; then
echo "--CBE Kernel will be installed" >> $SDKLOG
KERNEL_INSTALL_ACTION="INSTALL"
OPT_NO_KERNEL=0
BSC_HOST_FILES="$BSC_HOST_FILES $CBE_KERNEL_RPMS"
else
echo " Functions of the SDK will not operate properly "
echo " without the CBE Enhanced kernel. Please re-run"
echo " the installation and select the CBE Enhanced kernel"
echo ""
exit 1
fi
fi
fi
echo "--Exiting CBE check for kernel" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Determines what RPMs from the BSC site are required for the requested
# operation
#
# args:
# <none>
#
# return:
# 0 =
function CBE_check_for_simulator()
{
echo "--Entering CBE check for simulator" >> $SDKLOG
if ! (( OPT_NO_SIM )) ; then
# Determine if the system simulator should be installed
local msg=""
if [ "$TASK" = "depend" ] ; then
msg="Do you plan to install the Cell Full System Simulator?"
else
msg="Install Cell Full System Simulator?"
fi
prompt_yes_no "$msg"
if [ $? = 0 ] ; then
OPT_NO_SIM=0
echo "--Install Simulator selected" >> $SDKLOG
else
OPT_NO_SIM=1
echo "--No Simulator selected" >> $SDKLOG
fi
fi
echo "--Exiting CBE check for simulator" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Displays a confirmation prompt with an optional message. (unless OPT_FORCE
# is set, in which case a 'yes' answer is assumed)
#
# args:
# $1 = prompt string to display. (optional. default: 'Continue?')
#
# return:
# 0 = confirm
# 1 = deny
function prompt_yes_no()
{
if (( OPT_FORCE )) ; then
return 0
fi
local ans=""
local question="$1"
if [ "$question" = "" ] ; then
question="Continue?"
fi
while [ "$ans" != "y" ] && [ "$ans" != "n" ]
do
printf "$question (y/n):"
read -n 1 -r ans
printf "\n\n"
done
if [ "$ans" = "y" ] ; then
return 0
fi
return 1
}
#--------------------------------------------------------------------------
# Interactively confirms a remove/overwrite of a partially installed
# component
#
# args:
# $1 = display name of the component
#
# return:
# 0 = confirm
# 1 = deny
function confirm_partial_overwrite()
{
echo "--Entering confirm partial overwrite" >> $SDKLOG
if (( OPT_FORCE )) ; then
echo "--Partial overwrite is FORCED" >> $SDKLOG
return 0
fi
echo "--Confirming partial overwrite" >> $SDKLOG
echo ""
echo "A previous partial install of the $1 has been detected."
prompt_yes_no "Remove installed portions and re-install?"
return $?
}
#--------------------------------------------------------------------------
# Interactively confirms a remove/overwrite of a completely installed
# component
#
# args:
# $1 = display name of the component
#
# return:
# 0 = confirm
# 1 = deny
function confirm_complete_overwrite()
{
echo "--Entering confirm complete overwrite" >> $SDKLOG
if (( OPT_FORCE )) ; then
echo "--Complete overwrite is FORCED" >> $SDKLOG
return 0
fi
echo "--Confirming complete overwrite" >> $SDKLOG
echo "A previous install of the $1 has been detected."
prompt_yes_no "Remove installed portions and re-install?"
return $?
}
#--------------------------------------------------------------------------
# Verifies the host is running a tested distribution of Linux
#
# args:
# <none>
#
# return:
# 0 = success
# 1 = failure
function verify_host_os()
{
echo "--Entering verify host os" >> $SDKLOG
if [ "`cat /etc/redhat-release`" != "$LINUX_RELEASE" ] ; then
echo "WARNING: The SDK has not been tested with this GNU/Linux release."
echo "The tested GNU/Linux version is: $LINUX_RELEASE"
echo "Proceeding may result in a partial or failed SDK install."
return 1
fi
echo "--Exiting verifying the host os" >> $SDKLOG
return 0
}
#--------------------------------------------------------------------------
# Verifies the host is properly configured
#
# args:
# <none>
#
# return:
# 0 = success
# 1 = error
function verify_host_attributes()
{
echo "--Entering verify host attributes" >> $SDKLOG
# Ensure /opt is writable
if [ ! -w $OPT_DIR ] ; then
echo "ERROR: This user must be able to write files into $OPT_DIR"
echo "--/opt is not writable..exiting " >> $SDKLOG
return 1
fi
echo "--Exiting verify host attributes" >> $SDKLOG
return 0
}
#--------------------------------------------------------------------------
# Verifies the prerequisite RPMs are present. Depends on the variable
# HOST_PREREQS
#
# args:
# <none>
#
# return:
# 0 = all prereqs found
# 1 = prereqs missing
function verify_host_rpms()
{
local prereqs="$HOST_PREREQS"
echo "--Entering verify the prerequisite RPMs" >> $SDKLOG
if ! (( OPT_NO_SIM )) ; then
prereqs="$prereqs $IBM_SYSTEMSIM_PREREQS"
fi
local missing_prereqs=`rpm -q $prereqs | grep "not installed" | cut -d' ' -f2`
local missing_prereqs_formatted
local i
if [[ -n $missing_prereqs ]] ; then
echo "ERROR: Missing prerequisite package(s):"
for i in $missing_prereqs ; do
echo " $i"
echo "--Missing prerequisite package $i" >> $SDKLOG
missing_prereqs_formatted="$missing_prereqs_formatted $i"
done
echo ""
echo "Continuing without installing these packages will likely result in a partial"
echo "or failed SDK install. In most cases these packages may be installed by"
echo "typing 'yum install$missing_prereqs_formatted'"
return 1
fi
echo "--All prerequisite packages present on system" >> $SDKLOG
echo "--Exit verify the prerequisite RPMs" >> $SDKLOG
return 0
}
#--------------------------------------------------------------------------
# Downloads a list of files from the BSC site
#
# args:
# $* = list of files to downloads
#
# return:
# 0 = confirm
# !0 = error
function download()
{
local f
local err
echo "--Entering download files from $BSC_WEBSITE site" >> $SDKLOG
err=0
for f in $1 ; do
wget -nd -P $BSC_DOWNLOAD_DIR $BSC_WEBSITE/$f
if [ $? != 0 ] ; then
echo "--Download of $f failed" >> $SDKLOG
prompt_yes_no "ERROR: Download of $f failed. Continue?"
if [ $? != 0 ] ; then
exit 1
fi
let "err += 1"
fi
echo "--Download of $f was successful" >> $SDKLOG
echo "--Exiting download files from $BSC_WEBSITE" >> $SDKLOG
done
return $err
}
#--------------------------------------------------------------------------
# Ensures all required RPMs are present in the local directory
#
# args:
# none
#
# return:
# 0 = all RPMs present
# 1 = one or more RPMs missing
function verify_downloads()
{
local file
local err=0
local i
local missing_bsc_files;
local missing_alphaworks_files;
echo "--Entering verify downloads" >> $SDKLOG
for file in $BSC_HOST_FILES ; do
if [ ! -e $file ] && [ ! -e $BSC_DOWNLOAD_DIR/$file ] ; then
missing_bsc_files="$missing_bsc_files $file"
err=1
fi
done
for file in $IBM_HOST_FILES ; do
if [ ! -e $file ] ; then
missing_alphaworks_files="$missing_alphaworks_files $file"
err=1
fi
done
if [[ $err -eq 0 ]] ; then
echo "Verifying downloaded rpms..this may take a few minutes "
echo "If any of the rpms seem to be corrupted, please download the file again."
echo ""
for file in $BSC_HOST_FILES ; do
if [ -e $file ]; then
rpm -K $file > /dev/null
else
rpm -K $BSC_DOWNLOAD_DIR/$file > /dev/null
fi
if [ $? != 0 ] ; then
echo "ERROR: Corrupted RPM detected - $file "
echo "--Corrupted RPM file $file..exiting install" >> $SDKLOG
exit
fi
done
for file in $IBM_HOST_FILES ; do
rpm -K $file > /dev/null
if [ $? != 0 ] ; then
echo "ERROR: Corrupted RPM detected- $file "
echo "--Corrupted RPM file $file..exiting install" >> $SDKLOG
exit
fi
done
fi
if [[ $err -ne 0 ]] ; then
echo "WARNING! The following required file(s) for SDK install were not found"
echo "----------------------------------------------------------------------"
if [[ -n $missing_bsc_files ]] ; then
echo " Missing file(s):"
for i in $missing_bsc_files ; do
echo " $i"
echo "--Missing RPM from $BSC_WEBSITE : $i" >> $SDKLOG
done
echo ""
echo " Paths searched:"
echo " $PWD"
echo " $BSC_DOWNLOAD_DIR"
echo ""
echo " These files may be downloaded from:"
echo " $BSC_WEBSITE"
echo ""
echo ""
prompt_yes_no "Would you like to attempt automatically downloading these files to $BSC_DOWNLOAD_DIR?"
if [[ $? -eq 0 ]] ; then
echo "--Downloading $missing_bsc_files " >> $SDKLOG
download "$missing_bsc_files"
err=$?
fi
fi
if [[ -n $missing_alphaworks_files ]] ; then
echo " Missing file(s):"
for i in $missing_alphaworks_files ; do
echo " $i"
echo "--Missing RPM from $IBM_WEBSITE : $i" >> $SDKLOG
done
echo ""
echo " Paths searched:"
echo " $PWD"
echo " $BSC_DOWNLOAD_DIR"
echo ""
echo " These files may be downloaded from:"
echo " $IBM_WEBSITE"
echo ""
echo "*** These files must be manually downloaded ***"
echo ""
echo "--------------------------------------------------------------------------"
fi
fi
echo "--Exiting verify downloads" >> $SDKLOG
return $err;
}
#--------------------------------------------------------------------------
# Determines if the RPMs in a list are installed, partially installed, or
# not installed. This function will echo one of the following:
# - INSTALLED
# - PARTIAL
# - NOT_INSTALLED
#
# args:
# $1 = root path for RPMs
# $2 = list of RPMs
#
# return
# 0 =
function check_install_state()
{
local rootpath=$1
local rpm_list=$2
echo "--Entering check the install state of $rpm_list " >> $SDKLOG
rpm -q --root $rootpath $rpm_list 2>&1 > /dev/null
local rpm_missing_count=$?
local rpm_state
if [[ $rpm_missing_count -eq 0 ]] ; then
rpm_state="INSTALLED"
echo "--State = INSTALLED " >> $SDKLOG
else
local rpm_count=`echo $rpm_list | wc -w`
local rpm_found_count=$(( $rpm_count - $rpm_missing_count ))
if [[ $rpm_found_count -ne 0 ]] ; then
rpm_state="PARTIAL"
echo "--State = PARTIAL INSTALL " >> $SDKLOG
else
rpm_state="NOT_INSTALLED"
echo "--State = NOT_INSTALLED " >> $SDKLOG
fi
fi
echo $rpm_state
echo "--Exiting check the install state" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Examines the installed states of the various components, and prompts the
# user for permission to uninstall and overwrite if either a full or
# partial previous install is found
#
# args:
# none
#
# return
# 0 = all skip actions
# 1 = at least one install or reinstall action
function determine_install_actions()
{
echo "--Entering determine install action" >> $SDKLOG
local all_skip=0
if ! (( OPT_NO_SIM )) ; then
if [[ "$IBM_SYSTEMSIM_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$IBM_SYSTEMSIM_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_SYSTEMSIM_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$IBM_SYSTEMSIM_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$IBM_SYSTEMSIM_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_SYSTEMSIM_INSTALL_ACTION="REINSTALL"
fi
else
IBM_SYSTEMSIM_INSTALL_ACTION="INSTALL"
fi
if [[ $IBM_SYSTEMSIM_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$IBM_SYSTEMSIM_COMP_NAME state set to $IBM_SYSTEMSIM_INSTALL_ACTION " >> $SDKLOG
if [[ "$SYSROOT_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$SYSROOT_COMP_NAME"
if [ $? -eq 0 ] ; then
SYSROOT_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$SYSROOT_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$SYSROOT_COMP_NAME"
if [ $? -eq 0 ] ; then
SYSROOT_INSTALL_ACTION="REINSTALL"
fi
else
SYSROOT_INSTALL_ACTION="INSTALL"
fi
if [[ $SYSROOT_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$SYSROOT_COMP_NAME state set to $SYSROOT_INSTALL_ACTION " >> $SDKLOG
fi
if [[ "$GNU_TOOLCHAIN_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$GNU_TOOLCHAIN_COMP_NAME"
if [ $? -eq 0 ] ; then
GNU_TOOLCHAIN_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$GNU_TOOLCHAIN_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$GNU_TOOLCHAIN_COMP_NAME"
if [ $? -eq 0 ] ; then
GNU_TOOLCHAIN_INSTALL_ACTION="REINSTALL"
fi
else
GNU_TOOLCHAIN_INSTALL_ACTION="INSTALL"
fi
if [[ $GNU_TOOLCHAIN_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$GNU_TOOLCHAIN_COMP_NAME state set to $GNU_TOOLCHAIN_INSTALL_ACTION " >> $SDKLOG
if [[ "$IBM_XLC_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$IBM_XLC_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_XLC_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$IBM_XLC_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$IBM_XLC_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_XLC_INSTALL_ACTION="REINSTALL"
fi
else
IBM_XLC_INSTALL_ACTION="INSTALL"
fi
if [[ $IBM_XLC_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$IBM_XLC_COMP_NAME state set to $IBM_XLC_INSTALL_ACTION " >> $SDKLOG
if [[ "$IBM_SAMPLES_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$IBM_SAMPLES_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_SAMPLES_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$IBM_SAMPLES_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$IBM_SAMPLES_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_SAMPLES_INSTALL_ACTION="REINSTALL"
fi
else
IBM_SAMPLES_INSTALL_ACTION="INSTALL"
fi
if [[ $IBM_SAMPLES_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$IBM_SAMPLES_COMP_NAME state set to $IBM_SAMPLES_INSTALL_ACTION " >> $SDKLOG
if [[ "$LIBRARY_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$LIBRARY_COMP_NAME"
if [ $? -eq 0 ] ; then
LIBRARY_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$LIBRARY_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$LIBRARY_COMP_NAME"
if [ $? -eq 0 ] ; then
LIBRARY_INSTALL_ACTION="REINSTALL"
fi
else
LIBRARY_INSTALL_ACTION="INSTALL"
fi
if [[ $LIBRARY_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$LIBRARY_COMP_NAME state set to $LIBRARY_INSTALL_ACTION " >> $SDKLOG
#
# these components are only installed on Cell hardware
#
if (( CBE )) ; then
if [[ "$OPROFILE_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$OPROFILE_COMP_NAME"
if [ $? -eq 0 ] ; then
OPROFILE_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$OPROFILE_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$OPROFILE_COMP_NAME"
if [ $? -eq 0 ] ; then
OPROFILE_INSTALL_ACTION="REINSTALL"
fi
else
OPROFILE_INSTALL_ACTION="INSTALL"
fi
if [[ $OPROFILE_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$OPROFILE_COMP_NAME state set to $OPROFILE_INSTALL_ACTION " >> $SDKLOG
if [[ "$IBM_CELLPERF_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$IBM_CELLPERF_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_CELLPERF_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$IBM_CELLPERF_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$IBM_CELLPERF_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_CELLPERF_INSTALL_ACTION="REINSTALL"
fi
else
IBM_CELLPERF_INSTALL_ACTION="INSTALL"
fi
if [[ $IBM_CELLPERF_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$IBM_CELLPERF_COMP_NAME state set to $IBM_CELLPERF_INSTALL_ACTION " >> $SDKLOG
fi
if [ "$MACHINE" == "ppc64" ] ; then
if [[ "$FDPRPRO_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$FDPRPRO_COMP_NAME"
if [ $? -eq 0 ] ; then
FDPRPRO_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$FDPRPRO_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$FDPRPRO_COMP_NAME"
if [ $? -eq 0 ] ; then
FDPRPRO_INSTALL_ACTION="REINSTALL"
fi
else
FDPRPRO_INSTALL_ACTION="INSTALL"
fi
if [[ $FDPRPRO_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$FDPRPRO_COMP_NAME state set to $FDPRPRO_INSTALL_ACTION " >> $SDKLOG
fi
if [[ "$IBM_SPU_TIMING_INSTALLED" = "INSTALLED" ]] ; then
confirm_complete_overwrite "$IBM_SPU_TIMING_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_SPU_TIMING_INSTALL_ACTION="REINSTALL"
fi
elif [[ "$IBM_SPU_TIMING_INSTALLED" = "PARTIAL" ]]; then
confirm_partial_overwrite "$IBM_SPU_TIMING_COMP_NAME"
if [ $? -eq 0 ] ; then
IBM_SPU_TIMING_INSTALL_ACTION="REINSTALL"
fi
else
IBM_SPU_TIMING_INSTALL_ACTION="INSTALL"
fi
if [[ $IBM_SPU_TIMING_INSTALL_ACTION != "SKIP" ]] ; then
all_skip=1
fi
echo "--$IBM_SPU_TIMING_COMP_NAME state set to $IBM_SPU_TIMING_INSTALL_ACTION " >> $SDKLOG
# check to see if they chose to install the kernel
if [ "$KERNEL_INSTALL_ACTION" = "INSTALL" ] ; then
all_skip=1
fi
echo "--Exiting determine Install Action " >> $SDKLOG
return $all_skip
}
#--------------------------------------------------------------------------
# Checks for existing RPMs from a previous install.
#
# args:
# none
#
# return
# 0 =
function check_prev_rpms()
{
echo "--Entering check for a previous SDK install " >> $SDKLOG
SYSROOT_INSTALLED=$(check_install_state "/" "$SYSROOT_ALL_NAMES")
IBM_SYSTEMSIM_INSTALLED=$(check_install_state "/" "$IBM_SYSTEMSIM_ALL_NAMES")
GNU_TOOLCHAIN_INSTALLED=$(check_install_state "/" "$SCE_PPU_ALL_NAMES $SCE_SPU_ALL_NAMES")
IBM_XLC_INSTALLED=$(check_install_state "/" "$IBM_XLC_ALL_NAMES")
IBM_SAMPLES_INSTALLED=$(check_install_state "/" "$IBM_SAMPLES_NAME $IBM_ALF_ALL_NAMES")
LIBRARY_INSTALLED=$(check_install_state $LIB_SYSROOT_DIR "$LIBRARY_ALL_NAMES")
if (( CBE )) ; then
OPROFILE_INSTALLED=$(check_install_state "/" "$OPROFILE_ALL_NAMES")
IBM_CELLPERF_INSTALLED=$(check_install_state "/" "$IBM_CELLPERF_ALL_NAMES")
fi
if [ "$MACHINE" == "ppc64" ] ; then
FDPRPRO_INSTALLED=$(check_install_state "/" "$FDPRPRO_ALL_NAMES")
fi
IBM_SPU_TIMING_INSTALLED=$(check_install_state "/" "$IBM_SPU_TIMING_ALL_NAMES")
determine_install_actions
if [[ $? -eq 0 ]] ; then
echo "--All install actions are skip - end install " >> $SDKLOG
echo "No install actions -- exiting !!"
echo ""
exit 0
fi
echo "--Exiting check for a previous SDK install " >> $SDKLOG
}
#--------------------------------------------------------------------------
# Checks if the user is either root, or has the required sudo abilities
#
# args:
# none
#
# return
# 0 = success
# 1 = insufficent access
function check_root_authority()
{
echo "--Entering check root authority " >> $SDKLOG
if [ $UID != 0 ] ; then
echo "--$Install not running under Root..exiting " >> $SDKLOG
echo "ERROR: $SELF must be run as root"
return 1
fi
echo "--Exiting check root authority " >> $SDKLOG
return 0
}
#--------------------------------------------------------------------------
# Removes a list of RPMs by name ignoring dependencies
#
# args:
# $1 = root path for RPMs
# $2 = list of RPMs
#
# return
# 0 =
function remove_list_of_rpms()
{
local rootpath=$1
local rpm_list=$2
local f
echo "--Entering remove list of RPMs " >> $SDKLOG
for f in $rpm_list ; do
echo -n "$f ... "
rpm -q --root $rootpath $f > /dev/null 2>&1
if [ $? = 0 ] ; then
if [ "$rootpath" = "/" ]; then
rpm --erase -v --nodeps --allmatches $RPM_OPTIONS --root $rootpath $f
else
rpm --erase -v --nodeps --noscripts --allmatches $RPM_OPTIONS --root $rootpath $f
fi
echo "removed."
echo "--$f was removed " >> $SDKLOG
else
echo "not found"
echo "--$f not found " >> $SDKLOG
fi
done
echo "--Exiting remove list of RPMs " >> $SDKLOG
}
#--------------------------------------------------------------------------
# Populates the variable RPMLIST with the full paths of a given list of
# files by searching the local directory and $BSC_DOWNLOAD_DIR
#
# args:
# $* = RPMs to search for
#
# return
# 0 = all files found
# 1 = a file was not found
function build_rpm_list()
{
local file
RPMLIST=""
echo "--Entering build rpm list " >> $SDKLOG
echo "--Building the list of RPMs to install" >> $SDKLOG
for file in $* ; do
if [ -e $file ] ; then
RPMLIST="$RPMLIST $file"
elif [ -e $BSC_DOWNLOAD_DIR/$file ] ; then
RPMLIST="$RPMLIST $BSC_DOWNLOAD_DIR/$file"
else
echo "ERROR: $file not found"
echo "--Cannot build list..$file not found..exiting" >> $SDKLOG
return 1
fi
done
echo "--Building list of RPMs successfully completed " >> $SDKLOG
echo "--Exiting build rpm list " >> $SDKLOG
}
#--------------------------------------------------------------------------
# Places a copy of this script in $CELL_SDK_DIR
#
# args:
# none
#
# return
# 0 =
function install_self()
{
echo "--Entering install self " >> $SDKLOG
if [ ! -e $CELL_SDK_DIR/$SELF ] ; then
mkdir -p $CELL_SDK_DIR
fi
cp $FULL_SELF $CELL_SDK_DIR/$SELF
chown root.root $CELL_SDK_DIR/$SELF
chmod 755 $CELL_SDK_DIR/$SELF
echo "--Copy of $SELF put in $CELL_SDK_DIR " >> $SDKLOG
echo "--Exiting install self " >> $SDKLOG
}
#--------------------------------------------------------------------------
# Install or updates a list of RPMs by name
#
# args:
# $1 = component being installed
# $2 = additional RPM options
# $3 = root path for RPMs
# $4 = list of RPMs
#
# return
# 0 =
function install_list_of_rpms()
{
local compname=$1
local rpmopt=$2
local rootpath=$3
local rpm_list=$4
echo "--Entering install list of RPMs " >> $SDKLOG
echo ""
echo "$compname:"
echo ""
build_rpm_list $rpm_list
if [ $? != 0 ] ; then
echo "--Build rpm list for $compname failed..exiting " >> $SDKLOG
return 1
fi
if [ "$rootpath" = "/" ]; then
rpm -i $rpmopt $RPMLIST
else
rpm -i $rpmopt --nodeps --noscripts --ignorearch --root $rootpath $RPMLIST
fi
if [ $? != 0 ] ; then
echo "ERROR: failed to install $compname"
echo "--Install of $compname failed..exiting " >> $SDKLOG
return 1
fi
echo "--Exiting install list of RPMs " >> $SDKLOG
}
#--------------------------------------------------------------------------
# Installs all the RPMs selected. This function will also remove any
# existing RPMs if needed.
#
# args:
# none
#
# return
# 0 = success
# 1 = failure or abort
function install_rpms()
{
echo "--Entering install rpms " >> $SDKLOG
echo "The following action(s) will be taken:"
echo ""
if (( CBE )) ; then
echo " $KERNEL_INSTALL_ACTION the $KERNEL_COMP_NAME"
fi
echo " $IBM_SYSTEMSIM_INSTALL_ACTION the $IBM_SYSTEMSIM_COMP_NAME"
echo " $SYSROOT_INSTALL_ACTION the $SYSROOT_COMP_NAME"
echo " $GNU_TOOLCHAIN_INSTALL_ACTION the $GNU_TOOLCHAIN_COMP_NAME"
echo " $IBM_XLC_INSTALL_ACTION the $IBM_XLC_COMP_NAME"
echo " $IBM_SAMPLES_INSTALL_ACTION the $IBM_SAMPLES_COMP_NAME"
echo " $LIBRARY_INSTALL_ACTION the $LIBRARY_COMP_NAME"
if (( CBE )) ; then
echo " $OPROFILE_INSTALL_ACTION the $OPROFILE_COMP_NAME"
echo " $IBM_CELLPERF_INSTALL_ACTION the $IBM_CELLPERF_COMP_NAME"
fi
if [ "$MACHINE" == "ppc64" ] ; then
echo " $FDPRPRO_INSTALL_ACTION the $FDPRPRO_COMP_NAME"
fi
echo " $IBM_SPU_TIMING_INSTALL_ACTION the $IBM_SPU_TIMING_COMP_NAME"
echo ""
if ! (( OPT_FORCE )) ; then
local ans=""
prompt_yes_no
if [ "$?" != "0" ] ; then
return 1
fi
fi
if [ "$KERNEL_INSTALL_ACTION" = "INSTALL" ] ; then
install_list_of_rpms "$KERNEL_COMP_NAME" "-vh --force" "/" "$CBE_KERNEL_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
if ! (( OPT_NO_SIM )) ; then
#
# Simulator
#
if [ "$IBM_SYSTEMSIM_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$IBM_SYSTEMSIM_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms "/" "$IBM_SYSTEMSIM_ALL_NAMES"
fi
install_list_of_rpms "$IBM_SYSTEMSIM_COMP_NAME" "-vh" "/" "$IBM_SYSTEMSIM_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
#
# RPMS for SystemSim's sysroot disk.
#
if [ "$SYSROOT_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$SYSROOT_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms "/" "$SYSROOT_ALL_NAMES"
fi
install_list_of_rpms "$SYSROOT_COMP_NAME" "-vh" "/" "$SYSROOT_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
fi
#
# PPU and SPU tools for Cell
#
if [ "$GNU_TOOLCHAIN_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$GNU_TOOLCHAIN_INSTALL_ACTION" = "REINSTALL" ] ; then
echo "Removing existing packages:"
remove_list_of_rpms "/" "$SCE_PPU_ALL_NAMES $SCE_SPU_ALL_NAMES"
fi
install_list_of_rpms "$GNU_TOOLCHAIN_COMP_NAME" "-vh" "/" "$SCE_PPU_RPMS $SCE_SPU_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
#
# XLC
#
if [ "$IBM_XLC_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$IBM_XLC_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms "/" "$IBM_XLC_ALL_NAMES"
fi
install_list_of_rpms "$IBM_XLC_COMP_NAME" "-vh --nodeps" "/" "$IBM_XLC_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
#
# Samples
#
if [ "$IBM_SAMPLES_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$IBM_SAMPLES_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms "/" "$IBM_SAMPLES_NAME $IBM_ALF_ALL_NAMES"
fi
install_list_of_rpms "$IBM_SAMPLES_COMP_NAME" "-vh --force" "/" "$IBM_SAMPLES_RPMS $IBM_ALF_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
#
# LIBRARIES
#
if [ "$LIBRARY_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$LIBRARY_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms $LIB_SYSROOT_DIR "$LIBRARY_ALL_NAMES"
fi
install_list_of_rpms "$LIBRARY_COMP_NAME (32-bit)" "-vh --force $RPM_OPTIONS" "$LIB_SYSROOT_DIR" "$LIBRARY_PPC_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
install_list_of_rpms "$LIBRARY_COMP_NAME (64-bit)" "-vh --force $RPM_OPTIONS" "$LIB_SYSROOT_DIR" "$LIBRARY_PPC64_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
if (( CBE )) ; then
#
# OProfile
#
if [ "$OPROFILE_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$OPROFILE_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms "/" "$OPROFILE_ALL_NAMES"
fi
install_list_of_rpms "$OPROFILE_COMP_NAME" "-vh --force" "/" "$OPROFILE_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
#
# Cell Perf Counter
#
if [ "$IBM_CELLPERF_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$IBM_CELLPERF_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms "/" "$IBM_CELLPERF_ALL_NAMES"
fi
install_list_of_rpms "$IBM_CELLPERF_COMP_NAME" "-vh --force" "/" "$IBM_CELLPERF_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
fi
if [ "$MACHINE" == "ppc64" ] ; then
#
# Fdprpro
#
if [ "$FDPRPRO_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$FDPRPRO_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms "/" "$FDPRPRO_ALL_NAMES"
fi
install_list_of_rpms "$FDPRPRO_COMP_NAME" "-vh --force" "/" "$FDPRPRO_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
fi
#
# SPU Timing
#
if [ "$IBM_SPU_TIMING_INSTALL_ACTION" != "SKIP" ] ; then
if [ "$IBM_SPU_TIMING_INSTALL_ACTION" = "REINSTALL" ] ; then
remove_list_of_rpms "/" "$IBM_SPU_TIMING_ALL_NAMES"
fi
install_list_of_rpms "$IBM_SPU_TIMING_COMP_NAME" "-vh" "/" "$IBM_SPU_TIMING_RPMS"
if [[ $? -ne 0 ]] ; then
return 1;
fi
fi
echo "--Exiting install rpms " >> $SDKLOG
}
#--------------------------------------------------------------------------
# Performs integration between system root image and filesystem
#
# args:
# none
#
# return
# 0 = success
# 1 = error
function integrate()
{
echo "--Entering integrate" >> $SDKLOG
# synchronize a very limited subset of files from SYSROOT image to sysroot directory on non-native machines only
if [ "$MACHINE" != "ppc64" ] ; then
rpm -i --quiet --nodeps --noscripts --ignorearch --root $CELL_SDK_SYSROOT $EXTRA_CROSS_LIBS_RPMS > /dev/null 2>&1
fi
echo "--Exiting Integrate" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Builds the SDK libraries by calling either make_libs_samples_gnu or
# make_libs_samples_xlc
#
# args:
# none
#
# return
# 0 = success
# 1 = error
function build()
{
echo "--Entering build" >> $SDKLOG
check_root_authority
if [ $? != 0 ] ; then
return 1
fi
if (( OPT_USE_XLC )) ; then
make_libs_samples_xlc
echo "--Build samples using xlc" >> $SDKLOG
else
make_libs_samples_gnu
echo "--Build samples using gcc" >> $SDKLOG
fi
# only update the sysroot if it's installed
rpm -q $SYSROOT > /dev/null
if [ $? = 0 ] ; then
update_sysroot
fi
echo "--Exiting build" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Builds the SDK libraries and samples using GCC
#
# args:
# none
#
# return
# 0 =
function make_libs_samples_gnu()
{
echo "--Entering make libraries and samples using gcc" >> $SDKLOG
# Compile samples w/ GNU Toolchain and copy into SYSROOT directory (Buildtime)
clean_libs_samples
# build the libraries and samples
CURR_DIR=`pwd`
cd $CELL_SDK_DIR
sed -i -e 's/^ PPU32_COMPILER := xlc/# PPU32_COMPILER := xlc/' \
-e 's/^# PPU32_COMPILER := gcc/ PPU32_COMPILER := gcc/' \
-e 's/^ PPU64_COMPILER := xlc/# PPU64_COMPILER := xlc/' \
-e 's/^# PPU64_COMPILER := gcc/ PPU64_COMPILER := gcc/' \
-e 's/^ SPU_COMPILER := xlc/# SPU_COMPILER := xlc/' \
-e 's/^# SPU_COMPILER := gcc/ SPU_COMPILER := gcc/' \
make.env
cd src
make
cd $CURR_DIR
echo "--Exiting make libraries and samples using gcc" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Builds the SDK libraries and samples using XLC
#
# args:
# none
#
# return
# 0 =
function make_libs_samples_xlc()
{
echo "--Entering make libraries and samples using xlc" >> $SDKLOG
clean_libs_samples
# build the libraries and samples
CURR_DIR=`pwd`
cd $CELL_SDK_DIR
sed -i -e 's/^# PPU32_COMPILER := xlc/ PPU32_COMPILER := xlc/' \
-e 's/^ PPU32_COMPILER := gcc/# PPU32_COMPILER := gcc/' \
-e 's/^# PPU64_COMPILER := xlc/ PPU64_COMPILER := xlc/' \
-e 's/^ PPU64_COMPILER := gcc/# PPU64_COMPILER := gcc/' \
-e 's/^# SPU_COMPILER := xlc/ SPU_COMPILER := xlc/' \
-e 's/^ SPU_COMPILER := gcc/# SPU_COMPILER := gcc/' \
make.env
cd src
make
cd $CURR_DIR
echo "--Exiting make libraries and samples using xlc" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Cleans the built SDK libraries and samples
#
# args:
# none
#
# return
# 0 =
function clean_libs_samples()
{
echo "--Entering clean library/samples directory" >> $SDKLOG
# build the libraries and samples
pushd $CELL_SDK_DIR/src > /dev/null 2>&1
make clean
popd
echo "--Exit clean library/samples directory" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Synchronizes the system root directory with the system root image
#
# args:
# none
#
# return
# 0 = success
# 1 = failure
function update_sysroot()
{
echo "--Entering update sysroot" >> $SDKLOG
check_root_authority
if [ $? != 0 ] ; then
return 1
fi
# check to see if the mount point has been created
if [ ! -e $MOUNTPT_CELL_SDK_SYSROOT ] ; then
mkdir -p $MOUNTPT_CELL_SDK_SYSROOT
if [ $? != 0 ] ; then
echo "ERROR: Failed to create sysroot mount dir in /mnt."
echo "Check that you have write permission and/or turn off autofs."
return 1
fi
fi
# check if not mounted, if so mount and set flag so as to unmount
mounted=0
if [ "`cat /etc/mtab | grep $MOUNTPT_CELL_SDK_SYSROOT`" == "" ] ; then
echo "Mounting system root on $MOUNTPT_CELL_SDK_SYSROOT"
mount -o loop $SYSTEMSIM_IMAGES_CELL_DIR/$SYSROOT_DISK $MOUNTPT_CELL_SDK_SYSROOT
if [ $? != 0 ] ; then
echo "ERROR: Failed to mount sysroot image. Is $SYSROOT_RPMS installed?"
return 1
fi
mounted=1
fi
echo "Synchronizing sysroot directory with sysroot image"
echo "--synchronizing the sysroot directory with the sysroot image" >> $SDKLOG
# synchronize files from sysroot directory into the SYSROOT image
rsync -az $CELL_SDK_SYSROOT/usr $MOUNTPT_CELL_SDK_SYSROOT > /dev/null 2>&1
rsync -az --delete $CELL_SDK_SYSROOT/opt $MOUNTPT_CELL_SDK_SYSROOT > /dev/null 2>&1
if [ $mounted == 1 ] ; then
echo "Unmounting system root from $MOUNTPT_CELL_SDK_SYSROOT"
umount $MOUNTPT_CELL_SDK_SYSROOT
fi
echo "--Exiting update sysroot" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Checks if all install dependencies are met
#
# args:
# none
#
# return
# 0 = success
# 1 = failure
function depend()
{
echo "--Entering depend" >> $SDKLOG
check_root_authority
if [[ $? -ne 0 ]] ; then
exit 1
fi
if [[ "$TASK" = "install" ]] ; then
license_agreement
fi
verify_host_os
if [[ $? -ne 0 ]] ; then
prompt_yes_no "Continue?"
if [[ $? -ne 0 ]] ; then
exit 1
fi
fi
verify_host_attributes
if [[ $? -ne 0 ]] ; then
exit 1
fi
verify_host_rpms
if [[ $? -ne 0 ]] ; then
prompt_yes_no "Continue?"
if [[ $? -ne 0 ]] ; then
exit 1
fi
fi
if (( CBE )) ; then
CBE_check_for_kernel
CBE_check_for_simulator
echo "--Modifying fstab on cbe hardware for spufs if needed" >> $SDKLOG
grep -i spufs /etc/fstab >> /dev/null
if [ $? != 0 ] ; then
echo "spufs /spu spufs defaults 00" >> /etc/fstab
mkdir -p /spu
fi
fi
determine_alphaworks_rpms
determine_bsc_rpms
verify_downloads
if [[ $? -ne 0 ]] ; then
if [ "$TASK" = "depend" ]; then
echo ""
echo "ERROR: Missing SDK dependencies"
fi
if [ "$TASK" = "install" ]; then
echo ""
echo "ERROR: Missing SDK dependencies - canceling install"
fi
exit 1
fi
if [ "$TASK" = "depend" ]; then
echo ""
echo "SDK dependencies verified successfully"
fi
echo "--Exiting depend" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Installs the SDK
#
# args:
# none
#
# return
# 0 = success
# 1 = failure
function install()
{
echo "--Entering install" >> $SDKLOG
depend
check_prev_rpms
install_self
install_rpms
if [[ $? -ne 0 ]] ; then
exit 1;
fi
if ! (( OPT_NO_SIM )) ; then
integrate
if [[ $? -ne 0 ]] ; then
exit 1;
fi
fi
echo ""
echo "Cell SDK Install complete."
echo ""
echo " Please read the README.txt file in the root directory of the ISO image."
echo ""
echo "You can now build the samples by executing './cellsdk build [--gcc|--xlc]'."
echo "--Exiting install" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Uninstalls the SDK after prompting the user
#
# args:
# none
#
# return
# 0 = success
# 1 = aborted
function uninstall()
{
echo "--Entering uninstall" >> $SDKLOG
check_root_authority
if [[ $? -ne 0 ]] ; then
exit 1
fi
if ! (( OPT_FORCE )) ; then
echo ""
echo ""
echo "***** THIS WILL UNINSTALL ALL CELL SDK 2.1 FILES *****"
echo ""
echo ""
prompt_yes_no "Uninstall entire CELL SDK?"
if [ "$?" != "0" ] ; then
return 1
fi
fi
if [ "`cat /etc/mtab | grep $MOUNTPT_CELL_SDK_SYSROOT`" != "" ] ; then
echo "Unmounting sysroot from $MOUNTPT_CELL_SDK_SYSROOT"
umount $MOUNTPT_CELL_SDK_SYSROOT
fi
#
# Undo integration
#
if [ -e $MOUNTPT_CELL_SDK_SYSROOT ] ; then
echo "Deleting mountpoint $MOUNTPT_CELL_SDK_SYSROOT"
rm -rf $MOUNTPT_CELL_SDK_SYSROOT
fi
echo ""
echo "Removing packages"
echo ""
#
# Undo installation
#
if [ "$MACHINE" != "ppc64" ] ; then
remove_list_of_rpms $CELL_SDK_SYSROOT "$EXTRA_CROSS_LIBS" > /dev/null 2>&1
fi
remove_list_of_rpms "/" "$IBM_SYSTEMSIM_ALL_NAMES $SYSROOT_ALL_NAMES"
remove_list_of_rpms "/" "$SCE_PPU_ALL_NAMES $SCE_SPU_ALL_NAMES"
remove_list_of_rpms "/" "$IBM_XLC_ALL_NAMES"
remove_list_of_rpms "/" "$IBM_SAMPLES_NAME $IBM_ALF_ALL_NAMES"
remove_list_of_rpms $LIB_SYSROOT_DIR "$LIBRARY_ALL_NAMES"
if (( CBE )) ; then
remove_list_of_rpms "/" "$OPROFILE_ALL_NAMES "
remove_list_of_rpms "/" "$IBM_CELLPERF_ALL_NAMES "
fi
if [ "$MACHINE" == "ppc64" ] ; then
remove_list_of_rpms "/" "$FDPRPRO_ALL_NAMES"
fi
remove_list_of_rpms "/" "$IBM_SPU_TIMING_ALL_NAMES"
#
# Final cleanup
#
if [ -e $SYSTEMSIM_DIR ] ; then
echo ""
echo "Removing $IBM_SYSTEMSIM_COMP_NAME directory"
rm -rf $SYSTEMSIM_DIR
fi
if [ -e $CELL_SDK_INS_DIR ] ; then
echo ""
echo "Removing $IBM_SAMPLES_COMP_NAME directory"
rm -rf $CELL_SDK_INS_DIR
fi
if (( KERNEL_INSTALLED )) ; then
echo ""
echo ""
echo "NOTICE: $CBE_KERNEL cannot be automatically uninstalled, and must be manually removed"
echo ""
echo ""
fi
echo ""
echo "Uninstallation of SDK is complete."
}
#--------------------------------------------------------------------------
# Determines the installation state of a set of RPMs. Final state is
# contained in the global variable VERIFY_PACKAGE_LIST_STATUS
#
# args:
# $1 = flags to pass to RPM -q. If no flags are desired, this should be ""
# $* = list of RPMs to verify
#
# return
# 0 =
function verify_package_list()
{
local rootpath=$1
local rpm_list=$2
local i
#shift
local rpm_total=0
local rpm_missing=0
local rpm_found=0
echo "--Entering verify package list" >> $SDKLOG
for i in $rpm_list ; do
(( rpm_total++ ))
local pkg=${i/%.rpm/}
echo -n " $pkg ... "
rpm -q --quiet --root $rootpath $pkg > /dev/null 2>&1
if [ $? != 0 ] ; then
echo " missing"
echo "--Missing $pkg" >> $SDKLOG
(( rpm_missing++ ))
else
echo " found"
echo "--Found $pkg" >> $SDKLOG
(( rpm_found++ ))
fi
done
echo ""
if (( rpm_total == rpm_found )) ; then
VERIFY_PACKAGE_LIST_STATUS="Installed "
elif (( rpm_found != 0 )) ; then
VERIFY_PACKAGE_LIST_STATUS="Partially Installed"
else
VERIFY_PACKAGE_LIST_STATUS="Not Installed "
fi
VERIFY_PACKAGE_LIST_STATUS="$VERIFY_PACKAGE_LIST_STATUS ($rpm_found of $rpm_total found)"
echo "--Verify package list set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
echo "--Exiting verify package list" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Displays the installation state of the various SDK components
#
# args:
# <none>
#
# return
# 0 =
function verify()
{
local systemsim_status="Unknown"
local sysroot_image_status="Unknown"
local gnu_status="Unknown"
local xlc_status="N/A"
local sdk_status="Unknown"
local library_status="Unknown"
local numa_status="N/A (Cell only)"
local oprofile_status="N/A (Cell only)"
local kernel_status="N/A (Cell only)"
local fdprpro_status="N/A (Cell only)"
local cellperf_status="N/A (Cell only)"
local spu_timing_status="Unknown"
echo "--Entering verify" >> $SDKLOG
echo ""
echo "$IBM_SYSTEMSIM_COMP_NAME:"
verify_package_list "/" "$IBM_SYSTEMSIM_RPMS"
systemsim_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--system simulator status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
echo "$SYSROOT_COMP_NAME:"
verify_package_list "/" "$SYSROOT_RPMS"
sysroot_image_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--sysroot image status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
echo "$GNU_TOOLCHAIN_COMP_NAME:"
verify_package_list "/" "$SCE_SPU_RPMS $SCE_PPU_RPMS"
gnu_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--gnu status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
echo "$IBM_XLC_COMP_NAME:"
verify_package_list "/" "$IBM_XLC_RPMS"
xlc_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "$IBM_SAMPLES_COMP_NAME:"
verify_package_list "/" "$IBM_SAMPLES_RPMS $IBM_ALF_RPMS"
sdk_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--sdk status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
echo "$LIBRARY_COMP_NAME:"
verify_package_list $LIB_SYSROOT_DIR "$LIBRARY_PPC_RPMS $LIBRARY_PPC64_RPMS"
library_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--ppu library status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
if (( CBE )) ; then
echo "$OPROFILE_COMP_NAME:"
verify_package_list "/" "$OPROFILE_RPMS"
oprofile_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--oprofile status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
echo "$KERNEL_COMP_NAME:"
verify_package_list "/" "$CBE_KERNEL_RPMS"
kernel_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--kernel status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
echo "$IBM_CELLPERF_COMP_NAME:"
verify_package_list "/" "$IBM_CELLPERF_RPMS"
cellperf_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--cellperf status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
fi
if [ "$MACHINE" == "ppc64" ] ; then
echo "$FDPRPRO_COMP_NAME:"
verify_package_list "/" "$FDPRPRO_RPMS"
fdprpro_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--fdprpro status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
fi
echo "$IBM_SPU_TIMING_COMP_NAME:"
verify_package_list "/" "$IBM_SPU_TIMING_RPMS"
spu_timing_status="$VERIFY_PACKAGE_LIST_STATUS"
echo "--spu timing status set to $VERIFY_PACKAGE_LIST_STATUS" >> $SDKLOG
echo "INSTALLATION SUMMARY"
echo "=============================================================================="
echo "$IBM_SYSTEMSIM_COMP_NAME : $systemsim_status"
echo "$SYSROOT_COMP_NAME : $sysroot_image_status"
echo "$GNU_TOOLCHAIN_COMP_NAME : $gnu_status"
echo "$IBM_XLC_COMP_NAME : $xlc_status"
echo "$IBM_SAMPLES_COMP_NAME: $sdk_status"
echo "$LIBRARY_COMP_NAME : $library_status"
if (( CBE )) ; then
echo "$KERNEL_COMP_NAME : $kernel_status"
echo "$OPROFILE_COMP_NAME : $oprofile_status"
echo "$IBM_CELLPERF_COMP_NAME : $cellperf_status"
fi
if [ "$MACHINE" == "ppc64" ] ; then
echo "$FDPRPRO_COMP_NAME : $fdprpro_status"
fi
echo "$IBM_SPU_TIMING_COMP_NAME : $spu_timing_status"
echo "--Exiting verify" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Displays the version of the SDK
#
# args:
# none
#
# return
# 0 =
function version()
{
echo "$SDK_NAME $SDK_VERSION (build $SDK_BUILD)"
}
#--------------------------------------------------------------------------
# Displays the usage statement
#
# args:
# none
#
# return
# 0 =
function usage()
{
echo "Usage: $SELF <install|uninstall|depend|build|synch|verify|version> [OPTION...]"
echo ""
echo "Task 'install' and 'depend' options:"
echo " -f, --force assume 'yes' to all questions."
echo " --nosim do not install the IBM Cell BE Full System Simulator"
echo " --nokernel do not install the Cell BE Linux kernel (CBE hardware only)"
echo ""
echo "Task 'uninstall' options:"
echo " -f, --force assume 'yes' to all questions."
echo ""
echo "Task 'build' options:"
echo " -x, --xlc use XLC to compile the libraries and samples "
echo " -g, --gcc use GCC to compile the libraries and samples (default)"
echo ""
}
#--------------------------------------------------------------------------
# Parse command line options
#
# args:
# $1 = option to parse
#
# return
# 0 = known option
# 1 = unknown option
function parse_opt()
{
local opt=$1
echo "--Entering parse options" >> $SDKLOG
case $opt in
"-f"|"--force")
let "OPT_FORCE += 1"
;;
"--nosim")
let "OPT_NO_SIM += 1"
;;
"-x"|"--xlc")
let "OPT_USE_XLC += 1"
COMP_OPT_SPECIFIED=${COMP_OPT_SPECIFIED:-$opt}
;;
"-g"|"--gcc")
let "OPT_USE_GCC += 1"
COMP_OPT_SPECIFIED=${COMP_OPT_SPECIFIED:-$opt}
;;
"--nokernel")
let "OPT_NO_KERNEL += 1"
;;
*)
echo "$SELF: unknown option '$opt'"
return 1
;;
esac
echo "--Exiting parse options" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Validates command line options
#
# args:
# $1 = option to validate
#
# return
# 0 = valid option
# 1 = invalid option
function validate_opt()
{
local opt=$1
echo "--Entering validate options" >> $SDKLOG
# Ensure only one compiler is selected
if (( OPT_USE_GCC )) && (( OPT_USE_XLC )) ; then
echo "$SELF: option '$opt' conflicts with '$COMP_OPT_SPECIFIED'."
return 1
fi
echo "--Exiting validate options" >> $SDKLOG
}
#------------------------------------------------------------------------
# Displays an exit message and quits installation if the licenses are not
# accepted
#
# args:
# <none>
#
# return
# 0 =
function license_exit()
{
echo "*** installation aborted ***"
echo ""
echo "If you wish to know more about the Cell Broadband Engine please visit:"
echo " http://www-128.ibm.com/developerworks/power/cell/"
echo ""
exit -1
}
function check_prev_install()
{
echo "--Entering check prev install" >> $SDKLOG
IBM_11_SAMPLES=cell-sdk-lib-samples-1.1-10
IBM_20_SAMPLES=cell-sdk-lib-samples-2.0-5
rpm -q $IBM_11_SAMPLES > /dev/null
if [ $? -eq 0 ] ; then
echo ""
echo ""
echo "A previous version of Cell SDK has been detected - (1.1)."
echo "Please uninstall using the cellsdk script for that version"
echo ""
exit 1
fi
rpm -q $IBM_20_SAMPLES > /dev/null
if [ $? -eq 0 ] ; then
echo ""
echo ""
echo "A previous version of Cell SDK has been detected - (2.0)."
echo "Please uninstall using the cellsdk script for that version"
echo ""
exit 1
fi
echo "--Exiting check prev install" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Displays the license links and prompts for agreement
#
# args:
# <none>
#
# return
# 0 =
function license_agreement()
{
echo "--Entering license agreement" >> $SDKLOG
echo ""
echo "The IBM Cell Broadband Engine SDK contains components governed by the"
echo "following licenses:"
echo ""
echo "GNU Public License (GPL)"
echo " http://www.gnu.org/licenses/gpl.html"
echo ""
echo "Lesser GNU Public License (LGPL)"
echo " http://www.gnu.org/copyleft/lesser.html"
echo ""
echo "BSD License"
echo " http://www.opensource.org/licenses/bsd-license.php"
echo ""
echo "Common Public License (CPL)"
echo " http://www.eclipse.org/legal/cpl-v10.html"
echo ""
echo "International License Agreement for Early Release of Programs (ILAR)"
echo " http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?li_formnum=L-APAL-5L22XX"
echo " http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?li_formnum=L-MCHN-6MVMPV"
echo " http://www14.software.ibm.com/cgi-bin/weblap/lap.pl?li_formnum=L-MCHN-6VKTFH"
echo ""
echo "Installation and use of this software requires you to certify you have read the"
echo "licenses above, and accept their terms. To accept these terms, type 'yes' at"
echo "the prompt below. If you do not wish to accept, type 'no' or press 'ctrl-C' to"
echo "abort this program without installing."
echo ""
echo ""
printf "I have read and accept the licenses above (yes/NO): "
local ans
read -n 1 -r ans
if [ "$ans" != 'y' ] && [ "$ans" != 'Y' ] ; then
printf "\n\n"
license_exit
fi
read -n 1 -r ans
if [ "$ans" != 'e' ] && [ "$ans" != 'E' ] ; then
printf "\n\n"
license_exit
fi
read -n 1 -r ans
if [ "$ans" != 's' ] && [ "$ans" != 'S' ] ; then
printf "\n\n"
license_exit
fi
printf "\n\n"
echo "--Exiting license agreement" >> $SDKLOG
}
#--------------------------------------------------------------------------
# Continue with main line execution of script
# Set our name
SELF=`basename $0`
FULL_SELF=$0
# Ensure we have at least one argument
if [ $# -lt 1 ] ; then
usage
exit 1
fi
mkdir -p $BSC_DOWNLOAD_DIR
echo "--Installation started" > $SDKLOG
# Pop the first argument as the task
TASK=$1
shift
case $TASK in
install|depend|uninstall|build|synch|version|verify)
;;
-?|-h|--help|--usage)
usage
exit 0
;;
*)
echo "$SELF: unknown task '$TASK'"
usage
exit 1
;;
esac
while [ $# -ne 0 ] ; do
parse_opt $1
if [ $? != 0 ] ; then
exit 1
fi
validate_opt $1
if [ $? != 0 ] ; then
exit 1
fi
shift
done
echo "--Task selected is" $TASK >> $SDKLOG
case $TASK in
install)
check_prev_install
install
;;
uninstall)
uninstall
;;
build)
build
;;
synch)
update_sysroot
;;
depend)
depend
;;
verify)
verify
;;
version)
version
;;
*)
usage
exit 1
;;
esac
# end of script