#!/bin/bash
#
# test_linux_tools
#
# diverse tests bzgl Dataport Linux-Software zur Versionskontrolle
##############################
#
if ! which rpm >/dev/null 2>&1
 then
  exit 0
fi
#
cd `dirname $0`
#
. uls_header
#
( echo "D;$DT;$ULSHOSTNAME;Software;"
TMPFILE=/tmp/uls-packages.lst
#
rpm -qa --queryformat "%{NAME};%{VERSION};%{RELEASE}\n" >$TMPFILE
#
CATEGORIE="Tools"
#
awk -F '[ \t]*#' '
BEGIN { CAT = "Tools" }
{ if( $1 ~ /\[.*\]/ )
  { gsub("[][]", "", $1)
    CAT = $1
  }
  else if( $1 != "" )
  { gsub("[*]", "[^;]*", $1)
    if( c[CAT] )
      c[CAT] = c[CAT] "|"
    c[CAT] = c[CAT] "^" $1 ";"
  }
}
END { for( i in c )
        print i, c[i]
    }' /etc/uls/linux_tools.conf | while read cat reg
 do
  egrep "$reg" $TMPFILE | sed "s/^\(.*\);\(.*\);\(.*\)$/V;;;;$cat;\1;\2-\3;/"
done
#
rm $TMPFILE
#
# Suse-Release
#
if [[ -f /etc/SuSE-release ]]
 then
  W=`awk '/VERSION/{V=$3};/PATCHLEVEL/{P=$3};END{print V " SP" P}' /etc/SuSE-release`
  if [[ -n "$W" ]]
   then
    echo "V;;;;Linux;Suse-Release;\"$W\"; "
  fi
fi
) | send_test_tab
