Commit 157d20bb authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

grybkine: Simplify athena completion for job options, fix get_files completion (Scripts-00-01-87)

parent 3cbc9150
f_get_joboptions() {
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W "`lookup_joboptions.sh`" $cur ) )
return 0
}
f_get_local_joboptions() {
COMPREPLY=( $( compgen -W "`lookup_local_joboptions.sh`" -- $2 ) )
return 0
}
f_get_txtjoboptions() {
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W "`lookup_txtjoboptions.sh`" $cur ) )
return 0
}
f_get_pyjoboptions() {
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W "`lookup_pyjoboptions.sh`" $cur ) )
return 0
}
f_get_data() {
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W "`lookup_data.sh`" $cur ) )
return 0
}
f_get_scripts() {
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W "`lookup_scripts.sh`" $cur ) )
return 0
}
f_get_xmls() {
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W "`lookup_xmls.sh`" $cur ) )
return 0
}
f_get_files() {
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "-jo -scripts -data -xmls" -- $cur) )
return 0
fi
case "$prev" in
-jo)
COMPREPLY=( $( compgen -W "`lookup_joboptions.sh`" $cur ) )
return 0
;;
-scripts)
COMPREPLY=( $( compgen -W "`lookup_scripts.sh`" $cur ) )
return 0
;;
-data)
COMPREPLY=( $( compgen -W "`lookup_data.sh`" $cur ) )
return 0
;;
-xmls)
COMPREPLY=( $( compgen -W "`lookup_xmls.sh`" $cur ) )
return 0
;;
esac
}
if [ "${DO_EXT_ATHENA_TAB_COMPLETION:-}" = 1 ]; then
# echo "do expanded completion for athena"
complete -C lookup_joboptions.sh -X '!&*' athena athena.py
else
# echo "do only local completion for athena"
complete -C lookup_local_joboptions.sh -X '!&*' athena athena.py
fi
complete -F f_get_txtjoboptions check_joboptions
#complete -F f_get_pyjoboptions athena.py
complete -F f_get_joboptions get_joboptions
complete -F f_get_files get_files
complete athena 'p/*/`lookup_joboptions.sh`/'
complete athena.exe 'p/*/`lookup_joboptions.sh`/'
complete athena.py 'p/*/`lookup_joboptions.sh`/'
complete get_joboptions 'p/*/`lookup_joboptions.sh`/'
complete get_txtjoboptions 'p/*/`lookup_txtjoboptions.sh`/'
complete get_pyjoboptions 'p/*/`lookup_joboptions.sh`/'
complete check_joboptions 'p/*/`lookup_txtjoboptions.sh`/'
complete get_files 'p/-1/(-jo -scripts -data -xmls -symlink -copy)/' \
'n/-jo/`lookup_joboptions.sh`/' \
'n/-scripts/`lookup_scripts.sh`/' \
'n/-data/`lookup_data.sh`/' \
'n/-xmls/`lookup_xmls.sh`/' \
'N/-jo/`lookup_joboptions.sh`/' \
'N/-scripts/`lookup_scripts.sh`/' \
'N/-data/`lookup_data.sh`/' \
'N/-xmls/`lookup_xmls.sh`/' \
'c/-/(jo scripts data xmls symlink copy)/' \
'p/*/(-jo -scripts -data -xmls -symlink -copy)/'
function f_get_joboptions () { reply=(`lookup_joboptions.sh`);}
function f_get_local_joboptions { reply=(`lookup_local_joboptions.sh`);}
function f_get_txtjoboptions { reply=(`lookup_txtjoboptions.sh`);}
function f_get_pyjoboptions { reply=(`lookup_pyjoboptions.sh`);}
function f_get_data { reply=(`lookup_data.sh`);}
function f_get_scripts { reply=(`lookup_scripts.sh`);}
function f_get_xmls { reply=(`lookup_xmls.sh`);}
if compctl &> /dev/null; then
if [ "$DO_EXT_ATHENA_TAB_COMPLETION" = '1' ]; then
# echo "do expanded completion for athena"
compctl -K f_get_joboptions athena
compctl -K f_get_joboptions athena.py
else # echo "do only local completion for athena"
compctl -K f_get_local_joboptions athena
compctl -K f_get_local_joboptions athena.py
fi
compctl -K f_get_txtjoboptions check_joboptions
compctl -K f_get_joboptions get_joboptions
compctl -k "(-jo -scripts -data -xmls -symlink -copy)" \
-x 'r[-jo,-]' -K f_get_joboptions - \
'r[-scripts,-]' -K f_get_scripts - \
'r[-data,-]' -K f_get_data - \
'r[-xmls,-]' -K f_get_xmls -- get_files
fi
# Taken from CMT setup script https://trac.lal.in2p3.fr/CMT/browser/CMT/HEAD/src/setup.csh
# Define completion for interactive shell only
if ( $?0 == 0 ) then
if ( $?tcsh == 1 ) then
source ${SETUPCOMPLETIONROOT}/cmt/completion/setup_completion.tcsh
else if ( "${shell:t}" == "tcsh" ) then
source ${SETUPCOMPLETIONROOT}/cmt/completion/setup_completion.tcsh
endif
endif
unsetenv SETUPCOMPLETIONROOT
# Taken from CMT setup script https://trac.lal.in2p3.fr/CMT/browser/CMT/HEAD/src/setup.sh
# Define completion for interactive shell only
if [ -n "$-" ] && [ "${-#*i}" != "$-" ]; then
if [ -n "${ZSH_NAME-}" ]; then
. ${SETUPCOMPLETIONROOT}/cmt/completion/setup_completion.zsh
elif [ -n "${BASH-}" ]; then
. ${SETUPCOMPLETIONROOT}/cmt/completion/setup_completion.bash
fi
fi
unset SETUPCOMPLETIONROOT
package Scripts
author Christian Arnault <arnault@lal.in2p3.fr>
author Claire Bourdarios <Claire.Bourdarios@cern.ch>
author Jakob Nielsen <langgard@alf.nbi.dk>
author David Quarrie <David.Quarrie@cern.ch>
# Description:-
# This package contains the following release-related scripts:-
#
# checkreq.sh Checks requirements files
# get_joboptions get jo files from installation area to the current directory
# get_files get any file from installation area to the current directory
# lookup_xxx.sh helper scripts for the auto-completion mechanisms
#
# Refer to the doc/README file for more details. The scripts
# are installed in the InstallArea/share/bin directory within
# a release.
use AtlasPolicy AtlasPolicy-*
apply_pattern declare_scripts files="get_joboptions get_files \
lookup_local_joboptions.sh \
lookup_joboptions.sh lookup_scripts.sh lookup_xmls.sh lookup_data.sh \
# setup_completion.zsh setup_completion.tcsh setup_completion.bash \
checkDbgSymbols.sh"
# Source the tab completion script for jobOptions and other files
# For athena tab completion, on can have either:
# local completion - only look in '.' (default), or
# global completion - look in '.' and JOBOPTIONSSEARCHPATH
#
# To turn on the expanded version for athena use one of the tags:
#
# apply_tag extended_athena_tab_completion
# apply_tag ext_athena_tab_compl
#
set DO_EXT_ATHENA_TAB_COMPLETION "0" \
extended_athena_tab_completion "1" \
ext_athena_tab_compl "1"
set SETUPCOMPLETIONROOT $(SCRIPTSROOT)
setup_script $(SETUPCOMPLETIONROOT)/cmt/completion/setup_completion_main
Instructions for using checkreq.sh:
===================================
The checkreq.sh script parses cmt-packages and finds
missing and unneeded use-statements to be
inserted in or erased from the requirements file in the package.
It does this by finding all include-statements in all source- and
headerfiles in the package. Since a generic includestatement looks as
follows:
#include "<somepackagename>/<headerfile>.h"
the script can from these includestatements collect a list of
packages used by the present cmt-package. Not all includestatements, though,
have the simple form above and therefore the scripts uses some extra
parsing to determine used packages. Example: Most Geant4 headerfiles are
of the form G4xxx.h and therefore an includestatement for such a headerfile
is translated into a dependency on the (External) package Geant4.
Furthermore the script parses the requirementsfile looking for
linkopts-statements. Such linkopts-statements sometimes contain extra
libraries that need to be linked into binaries or libraries in the package.
These linkopts-statements are also translated into package-dependencies.
At the end a full list of package-dependencies are collected and these
dependencies are then compared with the list specified by use-statements
in the requirements file in the package. If any use-statements are missing
or not needed, the script outputs these.
A word or warning: The script tries as best as possible to identify all
missing and superflurious use-statements. However, it is not
always successful. The output of the script should therefore be
viewed critically.
The script can be run in two different ways: 1) either directly from
the cmt-directory of some package or 2) on packages and all their
subpackages in a release. An example is:
checkreq.sh -release 7.1.0 Calorimeter
that runs on all subpackages in the Calorimeter package in release 7.1.0
The first way of running can also be used with in conjunction with the
'cmt broadcast' command.
Options that the script understands:
-help : writes a small help.
-debug : the scripts writes extra debug information.
-writeuse: instead of writing the missing and unneeded packages, the
script writes the complete list of use-statements needed in
the requirements file. This requires that a section of CMTPATH
points to some AtlasRelease.
-ignore [ package ] : the script will ignore this package when parsing
packages.
-file <filename> : the script will ignore the packages specified in the
file <filename> when parsing packages.
-release <n> [ packages ] : run the script on the packages (and their
subpackages) in the release <n>
#!/usr/bin/env sh
# Author: Amir Farbin (afarbin@cern.ch)
#
# Wishlist: write a cleaner version in python!
pkgName=$1
rel=$2
#base=/afs/cern.ch/atlas/software/dist
base=$SITEROOT/atlas/software/dist
if [ $# -eq 0 ] ; then
echo
echo Checkout an ATLAS Athena package from CVS repository.
echo
echo Usage:
echo " addpkg <PackageName> [ <Release>/<Tag> ]"
echo
echo "<PackageName>: the full name of the package."
echo " (ex: Reconstruction/RecExample/RecExCommon)"
echo
echo "<Release>: the Athena release version. This is an optional parameter."
echo " If no release or tag is specified, addpkg will attempt to checkout "
echo " version corresponding to your present release version."
echo
echo "<Tag>: may be supplied instead of <Release>. (ex: RecExCommon-00-03-42)"
exit 1;
fi
if [ "X$rel" = "X" ] ; then
rel=`cmt show macro_value ATLAS_RELEASE`
echo Using release $rel.
fi
if [ -e $base/$rel ] ; then
pkgPath=$base/$rel/$pkgName
tag=`ls $pkgPath`
cmt co -r $tag $pkgName
else
cmt co -r $rel $pkgName
fi
#!/usr/bin/env bash
#
# Check the given shared libraries for debugging symbols
# Return code: 0 no debugging symbols found
# 1 at least one file contains debugging symbols
#
# Author: Frank Winklmeier
#
if [ $# -eq 0 ]; then
echo "Syntax: `basename $0` FILE..."
fi
# Ignore these libraries (regexp)
filter='HepMC|libfastjet|libCDFConesPlugin|libSISConePlugin|libsiscone|libulxmlrpcpp|libG4processes|libModelInteractions|libCascade_i|libMCTester_i|
|libColMan|libATLASConePlugin|libCMSIterativeConePlugin|libD0RunIIConePlugin|libEECambridgePlugin|libJadePlugin|libNestedDefsPlugin|libPxConePlugin|libTrackJetPlugin'
ignored=''
dbglibs=''
for lib in $@; do
if [[ $lib =~ $filter ]]; then
ignored="$ignored $lib"
continue
fi
if [[ ! -f ${lib} ]]; then
continue
fi
readelf -e ${lib} | grep debug_info &> /dev/null
if [ $? -eq 0 ]; then
dbglibs="$dbglibs $lib"
fi
done
if [[ -n $dbglibs ]]; then
echo "Libraries with debug symbols:"
echo "------------------------------"
for l in $dbglibs; do
echo $l
done
fi
if [[ -n $ignored ]]; then
echo
echo "Ignored the following libraries with debug symbols:"
echo "----------------------------------------------------"
for l in $ignored; do
echo $l
done
fi
if [[ -n $dbglibs ]]; then
exit 1
else
exit 0
fi
#set -x
all_jos=
all_dlls=
all_libs=
all_missing_libs=
all_comps=
function find_shared_library ()
{
name=$1
shift
for f in `echo ${LD_LIBRARY_PATH} | sed -e 's#:# #g'`; do
#echo $f
a=`if test -d ${f} ; then find ${f} -path "*/${name}"; fi`
if test ! "${a}" = ""; then
break
fi
done
echo ${a}
}
function find_joboptions_file ()
{
name=$1
shift
#f=`pwd`
#s=`if test -d ${f} ; then find ${f} -path "*/${name}"; fi`
#echo name=${name}
#if test "${s}" = ""; then
for f in `echo ${JOBOPTSEARCHPATH} | sed -e 's#:# #g'`; do
#echo $f
s=`if test -d ${f} ; then find ${f} -path "*/${name}"; fi`
if test ! "${s}" = ""; then
break
fi
done
#fi
echo ${s}
}
function tab ()
{
level=$1
shift
t=
while test "${level}" -gt 0; do
t="${t}.."
level=`expr ${level} - 1`
done
echo ${t}
}
function check ()
{
target=$1
shift
s=`echo "${all_jos}" | egrep -e "[ ]${target}[ ]"`
if test "${s}" = ""; then
all_jos="${all_jos} ${target} "
else
return
fi
level=$1
shift
tabulation=`tab ${level}`
file=`find_joboptions_file ${target}`
if test "${file}" = ""; then
echo "### ${target} not found"
return
fi
##echo file=${file}
#echo "------ DLLs:"
for f in `awk '/(DLLs).*{/,/}/ {print}' ${file} | sed -e 's#[^{]*{##' -e 's#}.*##' -e 's#[",]##g'`; do
#echo ${tabulation}${f}
s=`echo "${all_dlls}" | egrep -e "[ ]${f}[ ]"`
if test "${s}" = ""; then
all_dlls="${all_dlls} ${f} "
fi
g=`find_shared_library lib${f}.so`
if test "${g}" = ""; then
echo "#### lib${f}.so not found"
else
for a in `ldd ${g} | grep found | awk '{print $1}'`; do
s=`echo "${all_missing_libs}" | egrep -e "[ ]${a}[ ]"`
if test "${s}" = ""; then
all_missing_libs="${all_missing_libs} ${a} "
fi
done
###echo "all_libs=${all_libs}"
for a in `ldd ${g} | awk '{print $1 ":" $3}'`; do
n=`echo ${a} | cut -d: -f1`
s=`echo "${all_libs}" | egrep -e "[ ]${n}[:]"`
if test "${s}" = ""; then
all_libs="${all_libs} ${n}:${f} "
else
m=`echo "${all_libs}" | sed -e "s#.*[ ]${n}[:]##" -e 's#[ ].*##'`
mm=`echo "${m}" | egrep -e "[:,]${f}"`
###echo "#2##n=${n} m=${m} f=${f} mm=${mm}"
if test "${mm}" = ""; then
all_libs=`echo "${all_libs}" | sed -e "s#[ ]${n}[:][^ ]*#&,${f}#"`
fi
fi
done
#echo "------ Components:"
for a in `nm -C ${g} | egrep 'V vtable for.*Factory' | sed -e 's#.*<##' -e 's#>.*##'`; do
s=`echo "${all_comps}" | egrep -e "[ ]${a}[ ]"`
if test "${s}" = ""; then
all_comps="${all_comps} ${a} "
fi
done
fi
done
# echo "------ ExtSvcs"
# for f in `awk '/(ExtSvc).*{/,/}/ {print}' ${file} | sed -e 's#[^{]*{##' -e 's#}.*##' -e 's#[",]##g' -e "s#/.*##" | sort -u`; do
# echo ${tabulation}${f}
# done
# echo "------ includes"
incs=`grep '^#include' ${file} | sed -e 's#[^"]*"##' -e 's#".*##'`
for inc in `echo ${incs}`; do
#echo "inc=${inc}"
#jo=`find_joboptions_file ${inc}`
check ${inc} `expr ${level} + 1`
done
}
target=$1
shift
if test "${target}" = ""; then
echo "> checkjo.sh <jo-file>"
exit 1
fi
check ${target} 1
echo "#------ dlls"
for f in `echo ${all_dlls}`; do
echo ${f}
done
echo "#------ missing libraries"
for f in `echo ${all_missing_libs}`; do
echo ${f}
done
echo "#------ libraries"
for f in `echo ${all_libs}`; do
g=`echo ${f} | sed -e 's#[:]# from #'`
echo ${g}
done
echo "#------ joboption files"
for f in `echo ${all_jos}`; do
echo ${f}
done
echo "#------ components"
for f in `echo ${all_comps}`; do
echo ${f}
done
#!/usr/bin/env sh
# Author: Amir Farbin (afarbin@cern.ch)
#
# Wishlist: write a cleaner version in python! This script can be so much nicer...
if [ $# -ne 1 ]
then
echo
echo "Remove an existing ATLAS Athena Algorithm. Must be run from the"
echo "base or cmt directory of a package. The Algorithm should have been"
echo "created by newalg script."
echo
echo Usage:
echo " delalg <AlgorithmName>"
echo
echo " <AlgorithmName>: Name of the algorithm."
exit 1;
fi
algname=$1
myPWD=`pwd`
incmtdir=`pwd | grep cmt | wc | tr -s " " | cut -d" " -f 3`
if test $incmtdir -lt 1
then
cd cmt
incmtdir=`pwd | grep cmt | wc | tr -s " " | cut -d" " -f 3`
if test $incmtdir -lt 1
then
cd ../cmt
incmtdir=`pwd | grep cmt | wc | tr -s " " | cut -d" " -f 3`
fi
fi
if test $incmtdir -lt 1
then
echo Could not find cmt directory for package. Try switching to the"
echo "base or cmt directory of this package.
exit 1
fi
packagename=`cmt show macro_value package`