Portability patch for tools/check
PATCH 1/1 Portability patch for tools/check
Hi!
I did a little off-list discussion with Jan.
Attached is a patch, which makes the non-portable scripts in tools/check portable.
Christoph
tools/check/check_crypto_lib +10 -7
@@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL -function error { - echo - echo " *** Check for crypto library FAILED" - exit 1 -} +RC=0 set -e -ldconfig -p | grep -q libcrypto.so || error +ldconfig -v 2>&1 | grep -q libcrypto.so || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for crypto library FAILED" +fi + +exit ${RC}
tools/check/check_openssl_devel +10 -7
@@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD -function error { - echo - echo " *** Check for openssl headers FAILED" - exit 1 -} +RC=0 set -e -[ -e /usr/include/openssl/md5.h ] || error +test -r /usr/include/openssl/md5.h || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for openssl headers FAILED" +fi + +exit ${RC}
tools/check/check_python_devel +11 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD function error {
@@ -7,10 +7,19 @@ function error { exit 1 } +RC=0 + python -c ' import os.path, sys for p in sys.path: if os.path.exists(p + "/config/Makefile"): sys.exit(0) sys.exit(1) -' || error +' || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for python development environment FAILED" +fi + +exit ${RC}
tools/check/check_udev +28 -11
@@ -1,16 +1,33 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL -function error { - echo - echo ' *** Check for udev/hotplug FAILED' - exit 1 -} -[ -x "$(which udevinfo)" ] && \ - UDEV_VERSION=$(udevinfo -V | sed -e 's/^[^0-9]* \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/') +RC=0 -if [ -n "$UDEV_VERSION" ] && [ $UDEV_VERSION -ge 059 ]; then - exit 0 +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + TOOL="vnconfig" + which ${TOOL} 1>/dev/null 2>&1 || RC=1 + ;; +Linux) + TOOL="udevinfo" + test -x "$(which ${TOOL})" && \ + UDEV_VERSION=$(${TOOL} -V | sed -e 's/^[^0-9]* \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/') + if test -n "${UDEV_VERSION}" -a ${UDEV_VERSION} -ge 059; then + RC=0 + else + TOOL="hotplug" + which ${TOOL} 1>/dev/null 2>&1 || RC=1 + fi + ;; +*) + TOOL="" + echo "Unknown OS" && RC=1 + ;; +esac + +if test ${RC} -ne 0; then + echo + echo ' *** Check for ${TOOL} FAILED' fi -which hotplug 1>/dev/null 2>&1 || error +exit ${RC}
tools/check/check_x11_devel +11 -7
@@ -1,11 +1,15 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD -function error { - echo - echo " *** Check for x11 headers FAILED" - exit 1 -} +RC=0 set -e -[ -e /usr/include/X11/keysymdef.h ] || error +test -r /usr/include/X11/keysymdef.h || \ +test -r /usr/X11R6/include/X11/keysymdef.h || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for x11 headers FAILED" +fi + +exit ${RC}
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 6 lines · Christoph Egger
Hi!
I did a little off-list discussion with Jan.
Attached is a patch, which makes the non-portable scripts in
tools/checkportable.
I know I'm risking a flame war here, but why reinvent the wheel instead of using a dedicated build system (autotools, scons, cmake, whatever) ?
Quoted 32 lines · Christoph Egger
Hi!
I did a little off-list discussion with Jan.
Attached is a patch, which makes the non-portable scripts in
tools/checkportable.Christoph
[Snip]
diff -r
360eb996fa38tools/check/check_python_develtools/check/check_python_devel +3
-1@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD function error {@@ -7,10 +7,19 @@ function error { exit 1 } +RC=0 + python -c ' import os.path, sys for p in sys.path: if os.path.exists(p + "/config/Makefile"): sys.exit(0)
tools/check/check_python_devel function error { · line 25
Quoted 10 lines
tools/check/check_python_devel +8
-1sys.exit(1) -' || error +' || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for python development environment FAILED" +fi + +exit ${RC}
So we now have an uncalled error function at the top of the script. Is this intentional? What's non-portable about functions anyway? POSIX.1 defines a function definition syntax
(http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html).
Ewan.