|
这个SETUP.SH 要求软件在光盘下运行, 我想让它在硬盘下运行? 不知道如何编译它, 我编了一会, 没有成功, 下面是文件全文,请高手看看吧:
#!/bin/sh
#############################################################################
#
# Copyright (C) Cadence Design Systems, Inc. All rights
# reserved. Unpublished -- rights reserved under the
# copyright laws of the United States of America.
#
# RESTRICTED RIGHTS LEGEND
# Use, duplication, or disclosure by the Government is subject
# to restrictions as set forth in subparagraph (c)(l)(ii) of
# the Rights in Technical Data and Computer Software clause
# at DFARS 52.227-7013.
#
# Cadence Design Systems, Inc.
# 555 River Oaks Parkway
# San Jose, CA 95134 USA
#
#############################################################################
###############################################################
# This is a high level script that will figure out the platform
# that it is being executed on, tar off the appropriate softload
# All it needs as input is the directory onto which the Cadence
# Software needs to be installed.
# If the <install_dir> does not exist then it will try and create
# it. Else it will prompt the user for another install dir.
# If the user points to an existing install dir that is a Cadence
# hierarchy then SETUP.SH uses that else it errors out and
# demands another install dir.
#
################################################################
#
# Change Log:
# ===========
#
# Hariraj (03/16/99):
#--------------------
#
# Put in feedback from the code review on 03/05/99.
#
# Check for the allmediaMap.<platform> file
# while checking whether an existing directory is a Cadence
# hierarchy.
#
# Look for .FMrelease file, allmediaMap.CD_Plat file or any
# any allmediaMap for the release installed in the hierarchy
#
# Compare releases (hierarchy & CDROM) only if the existing
# directory has a Cadence hierarchy. And flag an error if the
# hierarchy release or the CD release cannot be determined.
#
# Fixed a couple of prompts
#
# Added comment on jsr and the subshell started with (
#
#
################################################################
# This has the copyright msg
copyrightMsg="
Copyright 1985-1999 by Cadence Design Systems Inc.
LICENSED SOFTWARE - REVERSE ASSEMBLY, REVERSE COMPILATION AND
REVERSE ENGINEERING PROHIBITED. The information contained in
this package is the proprietary property of Cadence Design Systems,
Inc., or its licensors, and may only be used in accordance with
the Cadence Design Systems license agreement under which this
package is provided.
Restricted Rights Notice to Government Users
Use duplication or disclosure by the Government is subject to
the restrictions as set forth in subparagraphs (c)(1)(ii) of the
Rights in Technical Data and Computer Software clause at
DFARS 252.227-7013. Unpublished - all rights reserved under the
copyright laws of the United States.
Cadence Design Systems, Inc.
555 River Oaks Parkway
San Jose, California 95134 USA
"
# This script should be platform independent.
# The definition of GetPlat() function
GetPlat () {
if [ -x /bin/uname ]; then #{
unameResult=`/bin/uname -a`
elif [ -x /usr/bin/uname ]; then
unameResult=`/usr/bin/uname -a`
else
unameResult=`uname -a`
fi
if [ "X$unameResult" = "X" ]; then # {
echo "UNKNOWN"
return 1
fi #}
platForm=`echo $unameResult | awk '{print $1}'`
case $platForm in #{
SunOS)
version=`echo $unameResult | awk '{print $3}'`
case $version in #{
4*) plat="sun4"
;;
5*) plat="sun4v"
;;
*) plat=""
esac #}
;;
HP-UX)
plat="hppa"
;;
AIX)
plat="ibmrs"
;;
Linux)
plat="lnx86"
;;
*) plat=""
;;
esac #}
if [ "X$plat" = "X" ]; then # {
echo "UNKNOWN"
return 1
fi #}
echo "$plat"
return 0
}
#Some functions which we have to be defined to keep this
#script platform independent.
EchoN () {
#Now before EchoN is used execPlat better be set
test -z "$execPlat" && {
echo "${NL}EchoN : Error, set execPlat before calling me.${NL}" 2>&1
return 1
}
if [ "X$execPlat" = "Xsun4" ]; then
echo -n "$*"
else
echo "$*\c"
fi
return 0
}
Page () {
#Relies on global variable execPlat being set
test -z "$execPlat" && {
echo "age : Error, set execPlat before calling me." 2>&1
return 1
}
if [ "X$execPlat" = "Xibmrs" ]; then
TERM=vt100 MORE="" more
else
MORE="" more
fi
return 0
}
Fullpath() { #print rooted path to arg dir
( cd $1 2>/dev/null && /bin/pwd |
sed 's@^/tmp_mnt/@/@' ) #print automount access dir
}
Dirname() { #print argument minus leaf, or .
case $1 in
*/* ) echo $1 | sed 's@/[^/]*$@/@' ;;
*) echo "." ;;
esac
}
Dirpath() { #print rooted path to arg - leaf
$jsr Fullpath `$jsr Dirname $1`
}
Affirmative() {
while : ; do
read Affirm < /dev/tty
case $Affirm in
[yY]*) return 0 ;;
[nN]*) return 1 ;;
*) $jsr EchoN "lease press y (yes) or n (no) : " ;;
esac
done
}
CheckCDROM() {
# Needs one argument
# The fully rooted path to the CDROM directory
cdDir=$1; shift
files="SOFTLOAD.TAR IMAGES.DIR/FS.0 IMAGES.DIR/FS.1 IMAGES.DIR/FS.2 IMAGES.DIR/FS.3 IMAGES.DIR/FS.4 IMAGES.DIR/FS.5"
for file in $files; do #{
if [ ! -s "$cdDir/$file" ]; then
$jsr EchoN "${NL}Missing file: $cdDir/$file"
$jsr EchoN "ERROR" > /tmp/setuperr$$
fi
done #}
if [ -s /tmp/setuperr$$ ]; then #{
return 1 #Failure
else
/bin/rm -f /tmp/setuperr$$
return 0 # Success
fi #}
} #End CheckCDROM
BadProdHier() {
#Needs one argument
#The fully rooted path to the production hierarchy
#Will RETURN 0 if the hierarchy is bad
prodHier=$1; shift
# If it is not an empty directory then it has to be a
# Cadence directory
# Check for existence of an allmediaMap file
allmediaMap=""
allmediaMap=`/bin/ls ${prodHier}/install/tmp/allmediaMap.* 2>/dev/null`
if [ ! -d "$prodHier" -o \
! -d "${prodHier}/install" -o \
! -d "${prodHier}/install/tmp" -o \
! -d "${prodHier}/install/pkgs" -o \
! -d "${prodHier}/install/pdts" -o \
"X$allmediaMap" = "X" ]; then #{
# This is a non empty directory that is not a Cadence
# install hierarchy
return 0
fi #}
return 1
} #end of BadProdHier
#Define some variables
progName=$0
# Earlier on jsr ould be set to call sub or something
# for some platforms. We just include it for historical
# reasons (for lack of something better on this)
jsr=''
supportedPlatforms="
The supported platforms are:
SunOS Operating System (sun4)
Solaris Operating System (sun4v)
HP-UX Operating System (hppa)
IBM AIX Operating System (ibmrs)
Linux Operating System (lnx86)
"
NL="
"
# End of Variables definition section
#Get the platform
execPlat=`$jsr GetPlat`
if [ "X$execPlat" = "XUNKNOWN" ]; then #{
echo "Error: Unsupported platform.${NL}${suppPlats}"
exit 1
fi #}
echo "$copyrightMsg" | Page
cdPathDir=
cdPathDir=`$jsr Dirpath $progName`
#
# For solaris, the cdPathDir could be /cdrom/<volume name>
# If it is that we fix it so that is is /cdrom/cdrom0
# Otherwise the <volume Name> will not work when the
# user mounts the next CD
#
if [ "X$execPlat" = "Xsun4v" ]; then #{
cddir=`/bin/ls -l /cdrom/cdrom0 2>/dev/null |\
awk '{ print $NF}' | sed -e 's@^\./@@'`
if [ "X$cddir" != "X" ]; then #{
case $cdPathDir in #{
*${cddir}* )
cdPathDir="/cdrom/cdrom0"
;;
* ) ;;
esac #}
fi #}
fi #}
if $jsr CheckCDROM $cdPathDir; then #{
$jsr EchoN "${NL}Located CDROM at $cdPathDir ${NL}"
else
$jsr EchoN "${NL}The $progName is not being run from the CDROM"
$jsr EchoN "${NL}Run $progName from the mounted CDROM${NL}${NL}"
exit 1
fi #}
while : ; do # {Keep on looping
$jsr EchoN "${NL}Specify path of install directory "
$jsr EchoN "[OR type [RETURN] to exit]: "
read instDir < /dev/tty
if [ "X$instDir" = "X" ]; then
$jsr EchoN "${NL}Exiting${NL}"
exit 0
fi
if [ ! -d "$instDir" ]; then #{ instDir does not exists
$jsr EchoN "${NL}Directory $instDir does not exist. Create? [y/n]: "
$jsr Affirmative || continue; #Go back & get instDir again
$jsr EchoN "${NL}${NL}Creating directory $instDir ${NL}"
umask 022
/bin/mkdir -p $instDir
if [ $? -ne 0 ]; then #{
$jsr EchoN "${NL}Error: Could not create installation "
$jsr EchoN "directory ${instDir}${NL}"
continue; # Go back and get another instDir
fi #}
else # If $instDir exists
# If it is not an empty directory then check
# whether it is a good hierarchy
if [ `/bin/ls -a $instDir | wc -l` -ne 2 ]; then #{
if $jsr BadProdHier $instDir; then #{
# Not a Cadence hierarchy
$jsr EchoN "${NL}The specified install directory is not empty."
$jsr EchoN "${NL}It does not appear to be a Cadence installation hierarchy.${NL}"
$jsr EchoN "${NL}The specified installation directory should be an empty directory or"
$jsr EchoN "${NL}an existing Cadence installation hierarchy"
$jsr EchoN "${NL}"
continue; #Go get another instDir
fi #}
# Now we check the release in the hierarchy and the release
# on the CD
# Now we check whether the release on CD matches the
# release in instDir
# Now we get the release & platform on the CD
# Start a subshell to extract FS.0 into /tmp directory
(/bin/mkdir -p /tmp/setup$$ 2>/dev/null
cd /tmp/setup$$;
/bin/tar -xf $cdPathDir/IMAGES.DIR/FS.0 ./install/tmp -b1 2>/dev/null )
allbundles=`/bin/ls /tmp/setup$$/install/tmp/allbundles.* 2>/dev/null`
if [ -s "$allbundles" ]; then #{
cdRel=`head -1 $allbundles | awk '{print $6}'`
cdPlat=`head -1 $allbundles | awk '{ print $5}'`
fi #}
/bin/rm -rf /tmp/setup$$
if [ -s "$instDir/.FMrelease" ]; then #{
hierRel=`head -1 $instDir/.FMrelease 2>/dev/null`
fi #}
if [ "X$hierRel" = "X" ]; then #{
allmediaMapP=""
allmediaMapP=`/bin/ls $instDir/install/tmp/allmediaMap.${cdPlat} 2>/dev/null`
allmediaMap=""
allmediaMap=`/bin/ls $instDir/install/tmp/allmediaMap.* 2>/dev/null`
# We look for allmediaMap file of the platform on the CD
# if that not found we look for any allmediaMap file
if [ -s "$allmediaMapP" ]; then #{
hierRel=`awk '{ if ( $2 == "CDROM" ) print $3}' $allmediaMapP | awk -F~ '{print $1}' | sort -u`
elif [ "X$allmediaMap" != "X" ]; then
/bin/rm -f /tmp/hierRel$$ #Use a file instead of a variable
for file in $allmediaMap; do #{
if [ -s "$file" ]; then #{
hRel=`awk '{ if ( $2 == "CDROM" ) print $3}' $file | awk -F~ '{print $1}' | sort -u`
if [ "X$hRel" = "X$cdRel" ]; then #{
echo $hRel > /tmp/hierRel$$
fi #}
fi #} If $file exists
done #}
if [ -s /tmp/hierRel$$ ]; then #{
hierRel=`head -1 /tmp/hierRel$$ 2>/dev/null`
fi #}
else # No media map file found
hierRel=""
fi #}
fi #} If hierRel is empty
# If both are empty set them to different values
# so that when we check the releases the comparison fails
if [ "X$hierRel" = "X" ]; then #{ check again
hierRel="unknown_hier_rel"
fi #}
if [ "X$cdRel" = "X" ]; then #{
cdRel="unknown_CD_rel"
fi #}
# Now we compare releases. If one or more are empty the
# releases will not be the same and the user will have
# to select another hierarchy
if [ "X$hierRel" != "X$cdRel" ]; then #{
$jsr EchoN "${NL}The install directory "
$jsr EchoN "$instDir is for $hierRel release."
$jsr EchoN "${NL}The CD on $cdPathDir is for $cdRel release."
$jsr EchoN "${NL}${NL}Cannot install $cdRel release in this install directory.${NL}"
continue #Go back to the top
fi #}
fi #}If $instDir is not empty
fi #} If instDir exists
# Convert instDir to fully rooted path
instDir=`$jsr Fullpath $instDir`
# Now we check whether the user has permissions to write to instDir
#Check whether the production hierarchy is writable
#If it is not
/bin/touch ${instDir}/.test 2>/dev/null
if [ $? -ne 0 ]; then #{
$jsr EchoN "${NL}It seems that you do not have write permissions"
$jsr EchoN "${NL}to ${instDir} or its subdirectories."
continue #Go back to pick another instDir
else
/bin/rm -f ${instDir}/.test
fi #}
# Now we have a directory with write permissions etc.
# Now we extract the softload binaries FS.$fsnum and
# the softload support files FS.0 in instDir
#{ Beginning of a sub shell
(cd ${instDir};
$jsr EchoN "${NL}Setting up softload for $execPlat in ${instDir} ${NL}"
case $execPlat in #{
sun4)
fsnum=2;;
hppa)
fsnum=3;;
ibmrs)
fsnum=4;;
sun4v)
fsnum=5;;
lnx86)
fsnum=6;;
esac #}
# We extract everything in install. This will create pkgs, pdts and tmp dirs
# to be created
umask 000
/bin/tar -xf $cdPathDir/IMAGES.DIR/FS.${fsnum} ./install -b1 2>/tmp/tarlog$$
# Don't need to check status here as we are checking log file
# Now we need to extract FS.0
/bin/tar -xf $cdPathDir/IMAGES.DIR/FS.0 ./install -b1 2>>/tmp/tarlog$$
) #At this point we have the latest softload binaries and
#} End of the subshell
# Since tar does not retrun a non 0 status even of there is an
# error we rely on this log file
# to trap errors from tar
# This section is outside the subshell as continue does not
# work very well from within it
if [ -s "/tmp/tarlog$$" ]; then #{
$jsr EchoN "${NL}The following tar errors were detected{NL}"
# We show them the file and then the following msgs
$jsr EchoN "${NL}Could not set up SoftLoad in $instDir">> /tmp/tarlog$$
$jsr EchoN "${NL}${NL}You must have write permissions to install directory ">> /tmp/tarlog$$
$jsr EchoN "and all its subdirectories${NL}and atleast 10 MB available disk ">> /tmp/tarlog$$
$jsr EchoN "space in install directory.${NL}">> /tmp/tarlog$$
/bin/cat /tmp/tarlog$$ | Page
/bin/rm -f /tmp/tarlog$$
continue
fi #}
# make sure everything is fine by checking that we have a good hierarchy
if $jsr BadProdHier $instDir; then
$jsr EchoN "${NL}Could not set up SoftLoad in $instDir${NL}"
continue;
fi #}
#
# So that the CD location is saved for SoftLoad
# Even if the user does not start SoftLoad now, the
# location of the CDROM is saved
#
$jsr EchoN "DeviceCD=\"${cdPathDir}\" ; export DeviceCD" > ${instDir}/install/.cdsloadrc.${execPlat}
$jsr EchoN "${NL}SoftLoad has been successfully setup in the directory:"
$jsr EchoN "${NL} ${instDir}"
$jsr EchoN "${NL}"
$jsr EchoN "${NL}You can install or update products by running:"
$jsr EchoN "${NL} $instDir/install/bin.${execPlat}/softload"
$jsr EchoN "${NL}${NL}Do you want to start softload? [y/n]: "
$jsr Affirmative || {\
$jsr EchoN "${NL}"
exit 0
}
binDir=${instDir}/install/bin.${execPlat}
$jsr EchoN "${NL}${NL}Starting up SoftLoad in GUI mode "
$jsr EchoN "${NL}${NL}DISPLAY environment variable is set to $DISPLAY"
$jsr EchoN "${NL}${NL}If you do not see the SoftLoad console "
$jsr EchoN "${NL}window or the SoftLoad ASCII menu and"
$jsr EchoN "${NL}$progName seems to be hanging then kill this "
$jsr EchoN "${NL}process."
$jsr EchoN "${NL}${NL}Set your DISPLAY environment variable to a proper"
$jsr EchoN "${NL}value and manually start SoftLoad by typing: "
$jsr EchoN "${NL} $binDir/softload ${NL}${NL}${NL}"
cd ${instDir};
exec /bin/sh $binDir/softload
done #} |
|