#!/bin/sh

# Copyright 2014 QLogic Corporation
# The contents of this file are subject to the terms of the
# QLogic End User License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the License at
# http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
# QLogic_End_User_Software_License.txt
# See the License for the specific language governing permissions
# and limitations under the License.

PATH="${PKG_INSTALL_ROOT}/usr/bin:${PKG_INSTALL_ROOT}/usr/sbin:${PATH}"
export PATH 

abort_install()
{
    echo ""
    echo "--------------------"
    echo "| $1"
    echo "| Aborting installation!"
    echo "--------------------"
    echo ""
    exit 1
}

# The ARCH environment variable is set appropriately when the package
# is created and made available for the installation scripts (pkginfo(4)).
if [ `uname -p` != "$ARCH" ]; then
    abort_install "ERROR: Package was not built for this system architecture."
fi

# The OSREL environment variable is set appropriately when the package
# is created and made available for the installation scripts (pkginfo(4)).
if [ `uname -r` != "$OSREL" ]; then
    abort_install "ERROR: Package was not built for this Solaris release."
fi

check_install()
{
    pkginfo $1 > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        abort_install "ERROR: The $1 package is installed (please remove)."
    fi
}

# Make sure BRCMbnx isn't already installed.
check_install BRCMbnx

exit 0

