From 3104eec4cff5df9efdfa7b24008732d49551a0a4 Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Wed, 26 Feb 2020 15:29:40 +0000 Subject: [PATCH 1/2] Enhance the output_env.sh script This commit adds additional information to the output_env.sh script of: * Linux distribution version (if available) * GDB version (if available) It also makes some information clearer: * the type of OpenSSL/GNUTLS version (legacy/default/next) * and whether certain versions are not installed, or not configured And it simplifies the error messages for absent tools. Signed-off-by: Simon Butcher --- scripts/output_env.sh | 85 +++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 31 deletions(-) diff --git a/scripts/output_env.sh b/scripts/output_env.sh index c809d46fe..62c5634b4 100755 --- a/scripts/output_env.sh +++ b/scripts/output_env.sh @@ -23,11 +23,15 @@ print_version() shift ARGS="$1" shift - FAIL_MSG="$1" + VARIANT=$1 shift + if [ ! -z $VARIANT ]; then + VARIANT=" ($VARIANT)" + fi + if ! `type "$BIN" > /dev/null 2>&1`; then - echo "* $FAIL_MSG" + echo " * ${BIN##*/}$VARIANT: Not found." return 0 fi @@ -41,81 +45,100 @@ print_version() VERSION_STR=`echo "$VERSION_STR" | $FILTER` done - echo "* ${BIN##*/}: $BIN: $VERSION_STR" + echo " * ${BIN##*/}$VARIANT: ${BIN} : ${VERSION_STR} " } -print_version "uname" "-a" "" +echo "Platform:\n" +if `type "lsb_release" > /dev/null 2>&1`; then + echo "Linux variant" + lsb_release -d -c +else + echo "Unknown Unix variant" +fi + echo +print_version "uname" "-a" "" +echo "\n" +echo "Tool Versions:\n" + if [ "${RUN_ARMCC:-1}" -ne 0 ]; then : "${ARMC5_CC:=armcc}" - print_version "$ARMC5_CC" "--vsn" "armcc not found!" "head -n 2" + print_version "$ARMC5_CC" "--vsn" "" "head -n 2" echo : "${ARMC6_CC:=armclang}" - print_version "$ARMC6_CC" "--vsn" "armclang not found!" "head -n 2" + print_version "$ARMC6_CC" "--vsn" "" "head -n 2" echo fi -print_version "arm-none-eabi-gcc" "--version" "gcc-arm not found!" "head -n 1" +print_version "arm-none-eabi-gcc" "--version" "" "head -n 1" echo -print_version "gcc" "--version" "gcc not found!" "head -n 1" +print_version "gcc" "--version" "" "head -n 1" echo -print_version "clang" "--version" "clang not found" "head -n 2" +print_version "clang" "--version" "" "head -n 2" echo -print_version "ldd" "--version" \ - "No ldd present: can't determine libc version!" \ - "head -n 1" +print_version "ldd" "--version" "" "head -n 1" echo -print_version "valgrind" "--version" "valgrind not found!" +print_version "valgrind" "--version" "" +echo + +print_version "gdb" "--version" "" "head -n 1" echo : ${OPENSSL:=openssl} -print_version "$OPENSSL" "version" "openssl not found!" +print_version "$OPENSSL" "version" "default" echo if [ -n "${OPENSSL_LEGACY+set}" ]; then - print_version "$OPENSSL_LEGACY" "version" "openssl legacy version not found!" - echo + print_version "$OPENSSL_LEGACY" "version" "legacy" +else + echo " * openssl (legacy): Not configured." fi +echo if [ -n "${OPENSSL_NEXT+set}" ]; then - print_version "$OPENSSL_NEXT" "version" "openssl next version not found!" - echo + print_version "$OPENSSL_NEXT" "version" "next" +else + echo " * openssl (next): Not configured." fi +echo : ${GNUTLS_CLI:=gnutls-cli} -print_version "$GNUTLS_CLI" "--version" "gnuTLS client not found!" "head -n 1" +print_version "$GNUTLS_CLI" "--version" "default" "head -n 1" echo : ${GNUTLS_SERV:=gnutls-serv} -print_version "$GNUTLS_SERV" "--version" "gnuTLS server not found!" "head -n 1" +print_version "$GNUTLS_SERV" "--version" "default" "head -n 1" echo if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then - print_version "$GNUTLS_LEGACY_CLI" "--version" \ - "gnuTLS client legacy version not found!" \ - "head -n 1" - echo + print_version "$GNUTLS_LEGACY_CLI" "--version" "legacy" "head -n 1" +else + echo " * gnutls-cli (legacy): Not configured." fi +echo if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then - print_version "$GNUTLS_LEGACY_SERV" "--version" \ - "gnuTLS server legacy version not found!" \ - "head -n 1" - echo + print_version "$GNUTLS_LEGACY_SERV" "--version" "legacy" "head -n 1" +else + echo " * gnutls-serv (legacy): Not configured." fi +echo -if `hash dpkg > /dev/null 2>&1`; then - echo "* asan:" +echo " * Installed asan versions:" +if `hash dpkg > /dev/null 2>&1` && `dpkg --get-selections|grep libasan > /dev/null` ; then + dpkg -s libasan5 2> /dev/null | grep -i version + dpkg -s libasan4 2> /dev/null | grep -i version + dpkg -s libasan3 2> /dev/null | grep -i version dpkg -s libasan2 2> /dev/null | grep -i version dpkg -s libasan1 2> /dev/null | grep -i version dpkg -s libasan0 2> /dev/null | grep -i version else - echo "* No dpkg present: can't determine asan version!" + echo " Either dpkg not present or no asan versions installed." fi echo From 679d2de36b5d168598a3cc92e379e385105fb7ac Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Thu, 27 Feb 2020 12:58:27 +0000 Subject: [PATCH 2/2] Make minor fixes to output_env.sh after review A number of clean-up improvements following review. * removal of redundant `` quotes * removal of non-portable echo "\n", in favour of additional echo commands * change to use of uname to detemine if the platform is Linux or not * revised formatting of output * change to dpkg-query from dpkg to find installed libasan variants Co-Authored-By: Gilles Peskine Signed-off-by: Simon Butcher --- scripts/output_env.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/scripts/output_env.sh b/scripts/output_env.sh index 62c5634b4..22bef92b9 100755 --- a/scripts/output_env.sh +++ b/scripts/output_env.sh @@ -26,11 +26,11 @@ print_version() VARIANT=$1 shift - if [ ! -z $VARIANT ]; then + if [ -n "$VARIANT" ]; then VARIANT=" ($VARIANT)" fi - if ! `type "$BIN" > /dev/null 2>&1`; then + if ! type "$BIN" > /dev/null 2>&1; then echo " * ${BIN##*/}$VARIANT: Not found." return 0 fi @@ -48,8 +48,10 @@ print_version() echo " * ${BIN##*/}$VARIANT: ${BIN} : ${VERSION_STR} " } -echo "Platform:\n" -if `type "lsb_release" > /dev/null 2>&1`; then +echo "** Platform:" +echo + +if [ `uname -s` = "Linux" ]; then echo "Linux variant" lsb_release -d -c else @@ -59,8 +61,10 @@ fi echo print_version "uname" "-a" "" -echo "\n" -echo "Tool Versions:\n" +echo +echo +echo "** Tool Versions:" +echo if [ "${RUN_ARMCC:-1}" -ne 0 ]; then : "${ARMC5_CC:=armcc}" @@ -131,14 +135,14 @@ fi echo echo " * Installed asan versions:" -if `hash dpkg > /dev/null 2>&1` && `dpkg --get-selections|grep libasan > /dev/null` ; then - dpkg -s libasan5 2> /dev/null | grep -i version - dpkg -s libasan4 2> /dev/null | grep -i version - dpkg -s libasan3 2> /dev/null | grep -i version - dpkg -s libasan2 2> /dev/null | grep -i version - dpkg -s libasan1 2> /dev/null | grep -i version - dpkg -s libasan0 2> /dev/null | grep -i version +if type dpkg-query >/dev/null 2>/dev/null; then + if ! dpkg-query -f '${Status} ${Package}: ${Version}\n' -W 'libasan*' | + awk '$3 == "installed" && $4 !~ /-/ {print $4, $5}' | + grep . + then + echo " No asan versions installed." + fi else - echo " Either dpkg not present or no asan versions installed." + echo " Unable to determine the asan version without dpkg." fi echo