From b7c3af934684e9ca54b02b3011cc75f757b9778e Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Thu, 31 Mar 2011 10:47:31 +0000 Subject: [PATCH] Improved check_linking script. * fixed problem with ':' seperated paths * verbose mode --- check_linking.sh | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/check_linking.sh b/check_linking.sh index cd3263e..7910337 100755 --- a/check_linking.sh +++ b/check_linking.sh @@ -6,18 +6,20 @@ # declare -r APP_NAME="${0##*/}" -declare -r VERSION="0.1" -declare -r FILES_FILE=1_files.rr +declare -r VERSION="0.1" +declare -r FILES_FILE=1_files.rr declare -r BROKEN_FILE=2_broken.rr -declare findMask -declare MODULE_NAMES -declare SEARCH_DIRS +declare VERBOSE=0 +declare findMask= +declare MODULE_NAMES= +declare SEARCH_DIRS= # extract path information from module file find_paths() { local pathspec=$1 - local PATHS=$( module display $MODULE_NAME |& awk "/.*path[[:space:]]+$pathspec[[:space:]]+/{ sub(/.*path[[:space:]]+$pathspec[[:space:]]+/,\"\"); print }" ) + local PATHS=$( module display $MODULE_NAME 2>&1 | awk "/.*path[[:space:]]+$pathspec[[:space:]]+/{ sub(/.*path[[:space:]]+$pathspec[[:space:]]+/,\"\"); print }" ) + PATHS=$(echo $PATHS | sed -e 's/:/ /g') for path in $PATHS; do SEARCH_DIRS+="$path " done @@ -59,6 +61,9 @@ for arg in $@; do print_usage exit 0 ;; + --verbose|-v) + VERBOSE=1 + ;; *) MODULE_NAMES+="${IFS}${arg}" ;; @@ -81,7 +86,13 @@ find ${SEARCH_DIRS[@]} $findMask -type f \( -perm -u+x -o -perm -g+x -o -perm -o files=($(<"$FILES_FILE")) for target_file in "${files[@]}"; do + if [ $VERBOSE = 1 ] ; then + echo -n "$target_file ..." + fi if ! file $target_file | grep ELF > /dev/null ; then + if [ $VERBOSE = 1 ] ; then + echo " skipped" + fi continue fi if [[ $target_file != *.la ]]; then @@ -98,7 +109,19 @@ for target_file in "${files[@]}"; do if [[ $MISSING_LIBS ]]; then echo "obj $target_file" >> "$BROKEN_FILE" - echo " broken $target_file (requires $MISSING_LIBS)" + if [ $VERBOSE = 1 ] ; then + echo " broken (requires $MISSING_LIBS)" + else + echo " broken $target_file (requires $MISSING_LIBS)" + fi + else + if [ $VERBOSE = 1 ] ; then + echo " ok" + fi + fi + else + if [ $VERBOSE = 1 ] ; then + echo " skipped la file." fi fi done