Warning, /Fireworks/Core/scripts/cmsShow is written in an unsupported language. File is not indexed.
0001 #!/usr/bin/env bash
0002 #set -x
0003
0004
0005 checkOS()
0006 {
0007 # Only 64-bit arch supported, and OSX version 10.6 or more.
0008
0009 osname=`uname -s`
0010 if [ f$osname = f"Darwin" ]; then
0011 arch=`sysctl hw | grep 64bit | awk '{print $2;}'`
0012 if [ $arch -eq 0 ]; then
0013 echo "###################################"
0014 echo "Only 64-bit OSX is supported!"
0015 echo "###################################"
0016 exit 1;
0017 fi
0018 osv=`sw_vers -productVersion |awk '{split($0,a,"\."); print a[1]a[2];}' `
0019 if [ "$osv" -lt "108" ]; then
0020 echo "#######################################"
0021 echo "Only version 10.8 or greater supported!"
0022 echo "#######################################"
0023 exit 1;
0024 fi
0025 else
0026 arch=`uname -m`
0027 if [ f$arch != f"x86_64" -a f$arch != f"amd64" ]; then
0028 echo "###################################"
0029 echo "Only 64-bit GNU/linux is supported!"
0030 echo "###################################"
0031 exit 1
0032 fi
0033 fi
0034 }
0035
0036 checkXConnection()
0037 {
0038 # Running via ssh can lead to dis-synchronization between server and
0039 # client due to bugs and incompatibilities of GLX implementations.
0040 # Here we apply some workarounds for known problems.
0041
0042 if [ f$osname != f"Darwin" -a -n "$SSH_CLIENT" ]; then
0043 export LIBGL_NO_DRAWARRAYS=1
0044 if ldd $ROOTSYS/lib/libRGL.so | grep libGL.so | grep -q nvidia; then
0045 echo "################################################################################"
0046 echo "# WARNING"
0047 echo "################################################################################"
0048 echo "You are running remotely on a machine that uses NVIDIA drivers."
0049 echo "This is known to cause problems with some client configurations."
0050 if [ -e /etc/redhat-release ]; then
0051 grep -q 'Scientific Linux' /etc/redhat-release && grep -q '5.' /etc/redhat-release
0052 is_sl5=$?
0053 grep -q 'CentOS' /etc/redhat-release && grep -q '5.' /etc/redhat-release
0054 is_centos5=$?
0055 if [ $is_sl5 = 0 -o $is_centos5 = 0 ]; then
0056 echo "We are running on SL5 or CentOS5."
0057 if [ -e /usr/lib64/libGL.so.1.2 ]; then
0058 echo "To avoid this problem libGL.so from MesaGL package will be preloaded."
0059 export LD_PRELOAD=/usr/lib64/libGL.so.1.2:$LD_PRELOAD
0060 else
0061 echo "Can not find replacement libGL.so from MesaGL."
0062 echo "If you run into trouble try installing mesa-libGL package on remote machine."
0063 fi
0064 fi
0065 fi
0066 echo "################################################################################"
0067 fi
0068 fi
0069
0070 # Require ZQuartz on 10.7 to avoid X11 freeze
0071 if [ f$osname = f"Darwin" ]; then
0072 osvt=`sw_vers -productVersion | awk '{if ( $1 >= 10.7 && $1 < 10.8 ) print $1;}'`
0073 if [ -n "$osvt" ]; then
0074 # echo "check quatz"
0075 dispXOrg=`glxinfo | grep display | grep xquartz`
0076 if [ -z "$dispXOrg" ]; then
0077 echo "WARNING: XQuartz installation is required on OSX 10.7."
0078 fi;
0079 fi;
0080 fi;
0081 }
0082
0083 setupEnv()
0084 {
0085 # strip of the directory name for this shell script
0086 export SHELLDIR=`dirname $0`
0087 # if no directory specified we need to use the local directory
0088 if [ ! -n "$SHELLDIR" ] || [ "$SHELLDIR" = "." ] ; then
0089 export SHELLDIR=$PWD
0090 fi
0091
0092 # see if we are running in standalone mode
0093 if [ ! -d $SHELLDIR/../../.SCRAM ] ; then
0094 export CMSSW_BASE=$SHELLDIR
0095 export CMSSW_SEARCH_PATH=".:$CMSSW_BASE"
0096 export CMSSW_DATA_PATH="."
0097 export ROOTSYS=$CMSSW_BASE/external/root
0098 export LD_LIBRARY_PATH=${CMSSW_BASE}/external/gcc/lib64:${ROOTSYS}/lib:${CMSSW_BASE}/external/lib:${CMSSW_BASE}/lib
0099 export DYLD_FALLBACK_LIBRARY_PATH=/opt/X11/lib:${LD_LIBRARY_PATH}
0100
0101 if [ -n "$DYLD_LIBRARY_PATH" ]; then
0102 echo "Warning: DYLD_LIBRARY_PATH not empty. Unsetting DYLD_LIBRARY_PATH."
0103 unset DYLD_LIBRARY_PATH
0104 fi
0105 export DYLD_LIBRARY_PATH=$CMSSW_BASE/external/gcc/lib64
0106 export PATH=${ROOTSYS}/bin:$PATH
0107 export ROOT_INCLUDE_PATH=${CMSSW_BASE}/external/gcc/include:${CMSSW_BASE}/external/gcc/include/x86_64-redhat-linux-gnu:${CMSSW_BASE}/external/gcc/include/backward:${CMSSW_BASE}/external/var-inc:$CMSSW_BASE/external/var-inc/sigc++:$CMSSW_BASE/external/var-inc/HepMC/include:${CMSSW_BASE}/src
0108 # move cmsShow.exe to libexec
0109 SHELLDIR=$SHELLDIR/libexec
0110 else
0111 export FROM_RELEASE=true
0112 fi
0113 }
0114
0115 printEnv()
0116 {
0117 # Needed only for debugging of a standalone version
0118 for i in CMSSW_BASE CMSSW_SEARCH_PATH CMSSW_DATA_PATH LD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH PATH SHELLDIR; do
0119 echo export $i=`eval echo \\$$i`
0120 done
0121 exit;
0122 }
0123
0124 parseOptions()
0125 {
0126 # We store in originalOptions all the options that need to be passed to the
0127 # actual cmsShow.exe executable but not those that are specific for the wrapper
0128 # file itself.
0129
0130 while [ $# -gt 0 ]
0131 do
0132 case "$1" in
0133 --soft) softflag=on ; originalOptions="${originalOptions} --soft";;
0134 -d|--debug) debugflag=on; originalOptions="${originalOptions} --debug";;
0135 -di|--debug-interactive) debuginteractiveflag=on;;
0136 --valgrind) valgrindflag=on;;
0137 --prompt) originalOptions="${originalOptions} $1 -r";;
0138 --eve) originalOptions="${originalOptions} --eve -r";;
0139 -r|--root-interactive) rootflag=on; originalOptions="${originalOptions} -r";;
0140 *) originalOptions="$originalOptions $1";;
0141 esac
0142 shift
0143 done
0144 }
0145
0146 writeSystemInfoToFile()
0147 {
0148 file=$1
0149 echo "" >> $file
0150 echo "System Info" >> $file
0151 uname -a >> $file
0152 glxinfo >> $file
0153 }
0154
0155 errorPrint()
0156 {
0157 # Wrap message to defined line width and add padding.
0158 echo $2 | awk -v m=$1 '{ txt=$0; m-=4; \
0159 ll=int(length(txt)/m) ; i=1; \
0160 if (length(txt)>(m +2)) { \
0161 { print " # " substr(txt,0,m) " # "} \
0162 while (i<ll) { { print " # " substr(txt,i*m+1,m) } i=i+1;} \
0163 fmt=sprintf("%%%ds", ll*m + m + 1 -length(txt) ); x=sprintf(fmt, "#"); \
0164 { print " # " substr(txt,i*m+1,m) " " x " " } \
0165 }\
0166 else { \
0167 fmt=sprintf("%%%ds", m +1 -length(txt) ); x=sprintf(fmt, "#"); \
0168 { print " # " (txt) " " x " "} } \
0169 }'
0170 }
0171
0172 ################################################################################
0173 # Main body of script starts here
0174 ################################################################################
0175
0176 setupEnv
0177 if [ -z "$FROM_RELEASE" ]; then
0178 checkOS
0179 fi
0180 checkXConnection
0181 parseOptions $@
0182
0183 if [ "X$softflag" = "Xon" ] ; then
0184 export LIBGL_ALWAYS_INDIRECT=1
0185 export LIBGL_DRIVERS_PATH=/tmp/
0186 export LIBGL_DEBUG=verbose
0187 export MESA_DEBUG=1
0188 fi
0189
0190
0191 # Developers cases -- run from gdb or valgrind.
0192 if [ "X$debuginteractiveflag" = Xon ] ; then
0193 if [[ `uname` == 'Linux' ]]; then
0194 gdbCmd="gdb --args $SHELLDIR/cmsShow.exe $originalOptions"
0195 else
0196 gdbCmd="lldb -- $SHELLDIR/cmsShow.exe $originalOptions"
0197 fi
0198 exec $gdbCmd
0199 elif [ "X$valgrindflag" = Xon ] ; then
0200 # MT: This should supposedly get rid of ROOT dicitonary reports etc. but it
0201 # didn't seem to work very well when I tried it (so I disabled error limit).
0202 # --suppressions=$ROOTSYS/etc/valgrind-root.supp
0203 valgrind --num-callers=30 --log-file=valgrind.log.$$ --freelist-vol=100000000 \
0204 --error-limit=no "$SHELLDIR/cmsShow.exe" $originalOptions
0205 exit;
0206 fi
0207
0208
0209 # Run cmsShow
0210 creport=`mktemp /tmp/cmsshow-crash-report-XXXXXXXX`.txt
0211 "$SHELLDIR/cmsShow.exe" $originalOptions 2> >( tee $creport)
0212 exitStatus=$?
0213 if [ $exitStatus -gt 0 ] && [ $exitStatus -ne 137 ] && [ "$rootflag" != "on" ] ; then
0214 writeSystemInfoToFile $creport
0215 "$SHELLDIR/cmsShowSendReport" ${creport}
0216 echo ""
0217 msgLen=75;
0218 awk -v msgLen=$msgLen 'BEGIN {printf(" %c", 35); i=0; while ( i <= msgLen) { printf( "%c", 35 ); ++i}; print ""; }'
0219 errorPrint $msgLen ""
0220 errorPrint $msgLen " Abnormal program termination!"
0221 errorPrint $msgLen ""
0222 errorPrint $msgLen "Please send:"
0223 errorPrint $msgLen "$creport"
0224 errorPrint $msgLen "to hn-cms-visualization@cern.ch."
0225 errorPrint $msgLen " "
0226 awk -v msgLen=$msgLen 'BEGIN {printf(" %c", 35); i=0; while ( i <= msgLen) { printf( "%c", 35 ); ++i}; print ""; }'
0227 echo ""
0228
0229 else
0230 rm $creport;
0231 fi
0232
0233 exit $exitStatus;
0234