/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Fireworks/Core/scripts/cmsShow
233 строки
8 KB
Alja Mrak-Tadel
Ignore LD_LIBRARY_PATH from the parent process.
24 июн 2015, 23:25
24 июн 2015, 23:25
e63fc48
Код
Авторство
О чём код?
#!/usr/bin/env bash #set -x checkOS() { # Only 64-bit arch supported, and OSX version 10.6 or more. osname=`uname -s` if [ f$osname = f"Darwin" ]; then arch=`sysctl hw | grep 64bit | awk '{print $2;}'` if [ $arch -eq 0 ]; then echo "###################################" echo "Only 64-bit OSX is supported!" echo "###################################" exit 1; fi osv=`sw_vers -productVersion |awk '{split($0,a,"\."); print a[1]a[2];}' ` if [ "$osv" -lt "108" ]; then echo "#######################################" echo "Only version 10.8 or greater supported!" echo "#######################################" exit 1; fi else arch=`uname -m` if [ f$arch != f"x86_64" -a f$arch != f"amd64" ]; then echo "###################################" echo "Only 64-bit GNU/linux is supported!" echo "###################################" exit 1 fi fi } checkXConnection() { # Running via ssh can lead to dis-synchronization between server and # client due to bugs and incompatibilities of GLX implementations. # Here we apply some workarounds for known problems. if [ f$osname != f"Darwin" -a -n "$SSH_CLIENT" ]; then export LIBGL_NO_DRAWARRAYS=1 if ldd $ROOTSYS/lib/libRGL.so | grep libGL.so | grep -q nvidia; then echo "################################################################################" echo "# WARNING" echo "################################################################################" echo "You are running remotely on a machine that uses NVIDIA drivers." echo "This is known to cause problems with some client configurations." if [ -e /etc/redhat-release ]; then grep -q 'Scientific Linux' /etc/redhat-release && grep -q '5.' /etc/redhat-release is_sl5=$? grep -q 'CentOS' /etc/redhat-release && grep -q '5.' /etc/redhat-release is_centos5=$? if [ $is_sl5 = 0 -o $is_centos5 = 0 ]; then echo "We are running on SL5 or CentOS5." if [ -e /usr/lib64/libGL.so.1.2 ]; then echo "To avoid this problem libGL.so from MesaGL package will be preloaded." export LD_PRELOAD=/usr/lib64/libGL.so.1.2:$LD_PRELOAD else echo "Can not find replacement libGL.so from MesaGL." echo "If you run into trouble try installing mesa-libGL package on remote machine." fi fi fi echo "################################################################################" fi fi # Require ZQuartz on 10.7 to avoid X11 freeze if [ f$osname = f"Darwin" ]; then osvt=`sw_vers -productVersion | awk '{if ( $1 >= 10.7 && $1 < 10.8 ) print $1;}'` if [ -n "$osvt" ]; then # echo "check quatz" dispXOrg=`glxinfo | grep display | grep xquartz` if [ -z "$dispXOrg" ]; then echo "WARNING: XQuartz installation is required on OSX 10.7." fi; fi; fi; } setupEnv() { # strip of the directory name for this shell script export SHELLDIR=`dirname $0` # if no directory specified we need to use the local directory if [ ! -n "$SHELLDIR" ] || [ "$SHELLDIR" = "." ] ; then export SHELLDIR=$PWD fi # see if we are running in standalone mode if [ ! -d $SHELLDIR/../../.SCRAM ] ; then export CMSSW_BASE=$SHELLDIR export CMSSW_SEARCH_PATH=".:$CMSSW_BASE" export CMSSW_DATA_PATH="." export ROOTSYS=$CMSSW_BASE/external/root export LD_LIBRARY_PATH=${CMSSW_BASE}/external/gcc/lib64:${ROOTSYS}/lib:${CMSSW_BASE}/external/lib:${CMSSW_BASE}/lib export DYLD_FALLBACK_LIBRARY_PATH=/opt/X11/lib:${LD_LIBRARY_PATH} if [ -n "$DYLD_LIBRARY_PATH" ]; then echo "Warning: DYLD_LIBRARY_PATH not empty. Unsetting DYLD_LIBRARY_PATH." unset DYLD_LIBRARY_PATH fi export DYLD_LIBRARY_PATH=$CMSSW_BASE/external/gcc/lib64 export PATH=${ROOTSYS}/bin:$PATH 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 # move cmsShow.exe to libexec SHELLDIR=$SHELLDIR/libexec else export FROM_RELEASE=true fi } printEnv() { # Needed only for debugging of a standalone version for i in CMSSW_BASE CMSSW_SEARCH_PATH CMSSW_DATA_PATH LD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH PATH SHELLDIR; do echo export $i=`eval echo \\$$i` done exit; } parseOptions() { # We store in originalOptions all the options that need to be passed to the # actual cmsShow.exe executable but not those that are specific for the wrapper # file itself. while [ $# -gt 0 ] do case "$1" in --soft) softflag=on ; originalOptions="${originalOptions} --soft";; -d|--debug) debugflag=on; originalOptions="${originalOptions} --debug";; -di|--debug-interactive) debuginteractiveflag=on;; --valgrind) valgrindflag=on;; --prompt) originalOptions="${originalOptions} $1 -r";; --eve) originalOptions="${originalOptions} --eve -r";; -r|--root-interactive) rootflag=on; originalOptions="${originalOptions} -r";; *) originalOptions="$originalOptions $1";; esac shift done } writeSystemInfoToFile() { file=$1 echo "" >> $file echo "System Info" >> $file uname -a >> $file glxinfo >> $file } errorPrint() { # Wrap message to defined line width and add padding. echo $2 | awk -v m=$1 '{ txt=$0; m-=4; \ ll=int(length(txt)/m) ; i=1; \ if (length(txt)>(m +2)) { \ { print " # " substr(txt,0,m) " # "} \ while (i<ll) { { print " # " substr(txt,i*m+1,m) } i=i+1;} \ fmt=sprintf("%%%ds", ll*m + m + 1 -length(txt) ); x=sprintf(fmt, "#"); \ { print " # " substr(txt,i*m+1,m) " " x " " } \ }\ else { \ fmt=sprintf("%%%ds", m +1 -length(txt) ); x=sprintf(fmt, "#"); \ { print " # " (txt) " " x " "} } \ }' } ################################################################################ # Main body of script starts here ################################################################################ setupEnv if [ -z "$FROM_RELEASE" ]; then checkOS fi checkXConnection parseOptions $@ if [ "X$softflag" = "Xon" ] ; then export LIBGL_ALWAYS_INDIRECT=1 export LIBGL_DRIVERS_PATH=/tmp/ export LIBGL_DEBUG=verbose export MESA_DEBUG=1 fi # Developers cases -- run from gdb or valgrind. if [ "X$debuginteractiveflag" = Xon ] ; then if [[ `uname` == 'Linux' ]]; then gdbCmd="gdb --args $SHELLDIR/cmsShow.exe $originalOptions" else gdbCmd="lldb -- $SHELLDIR/cmsShow.exe $originalOptions" fi exec $gdbCmd elif [ "X$valgrindflag" = Xon ] ; then # MT: This should supposedly get rid of ROOT dicitonary reports etc. but it # didn't seem to work very well when I tried it (so I disabled error limit). # --suppressions=$ROOTSYS/etc/valgrind-root.supp valgrind --num-callers=30 --log-file=valgrind.log.$$ --freelist-vol=100000000 \ --error-limit=no "$SHELLDIR/cmsShow.exe" $originalOptions exit; fi # Run cmsShow creport=`mktemp /tmp/cmsshow-crash-report-XXXXXXXX`.txt "$SHELLDIR/cmsShow.exe" $originalOptions 2> >( tee $creport) exitStatus=$? if [ $exitStatus -gt 0 ] && [ $exitStatus -ne 137 ] && [ "$rootflag" != "on" ] ; then writeSystemInfoToFile $creport "$SHELLDIR/cmsShowSendReport" ${creport} echo "" msgLen=75; awk -v msgLen=$msgLen 'BEGIN {printf(" %c", 35); i=0; while ( i <= msgLen) { printf( "%c", 35 ); ++i}; print ""; }' errorPrint $msgLen "" errorPrint $msgLen " Abnormal program termination!" errorPrint $msgLen "" errorPrint $msgLen "Please send:" errorPrint $msgLen "$creport" errorPrint $msgLen "to hn-cms-visualization@cern.ch." errorPrint $msgLen " " awk -v msgLen=$msgLen 'BEGIN {printf(" %c", 35); i=0; while ( i <= msgLen) { printf( "%c", 35 ); ++i}; print ""; }' echo "" else rm $creport; fi exit $exitStatus;