[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 2 of 2] Make tools/check scripts cross-friendly
check_udev fails due to a typo in the patch. See inline for other comments. Christoph On Saturday 19 January 2008 05:02:31 Aron Griffis wrote: > # HG changeset patch > # User Aron Griffis <aron@xxxxxx> > # Date 1200715193 18000 > # Node ID 735710fbd87c8c3701bb2e33746500793acf14bf > # Parent 79cf8ffbc6678f201d35724bf083ea9749818597 > Make tools/check scripts cross-friendly > > This patch introduces tools/check/funcs.sh with some > cross-friendly abstractions, then modifies the check_* > scripts to use them. > > Signed-off-by: Aron Griffis <aron@xxxxxx> > [snip] > diff -r 79cf8ffbc667 -r 735710fbd87c tools/check/check_udev > --- a/tools/check/check_udev Fri Jan 18 22:59:53 2008 -0500 > +++ b/tools/check/check_udev Fri Jan 18 22:59:53 2008 -0500 > @@ -1,34 +1,19 @@ > #!/bin/sh > # CHECK-INSTALL > > -RC=0 > +. funcs.sh > > -case ${OS} in > +case $OS in > OpenBSD|NetBSD|FreeBSD) > - TOOL="vnconfig" > - which ${TOOL} 1>/dev/null 2>&1 || RC=1 > + has_or_fail vncconfig ^^^^^^ Typo!! > ;; > Linux) > - TOOL="udevinfo" > - UDEV_VERSION="0" > - test -x "$(which ${TOOL} 2>/dev/null)" && \ > - UDEV_VERSION=$(${TOOL} -V | sed -e 's/^[^0-9]* > \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/') - if test "${UDEV_VERSION}" -ge 059; then > - RC=0 > - else > - TOOL="hotplug" > - which ${TOOL} 1>/dev/null 2>&1 || RC=1 > - fi > + has_or_fail udevinfo > + [ "`udevinfo -V | awk '{print $NF}'`" -ge 59 ] 2>/dev/null || \ > + has hotplug || \ > + fail "udev is too old, upgrade to version 59 or later" > ;; > *) > - TOOL="" > - echo "Unknown OS" && RC=1 > + fail "unknown OS" > ;; > esac > - > -if test ${RC} -ne 0; then > - echo > - echo " *** Check for ${TOOL} FAILED" > -fi > - > -exit ${RC} > diff -r 79cf8ffbc667 -r 735710fbd87c tools/check/check_x11_devel > --- a/tools/check/check_x11_devel Fri Jan 18 22:59:53 2008 -0500 > +++ b/tools/check/check_x11_devel Fri Jan 18 22:59:53 2008 -0500 > @@ -1,15 +1,8 @@ > #!/bin/sh > # CHECK-BUILD > > -RC=0 > +. funcs.sh > > -set -e > -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} > +has_header X11/keysymdef.h || \ > +has_header /usr/X11R6/include/X11/keysymdef.h || \ > +fail "can't find X11 headers" > diff -r 79cf8ffbc667 -r 735710fbd87c tools/check/check_xgettext > --- a/tools/check/check_xgettext Fri Jan 18 22:59:53 2008 -0500 > +++ b/tools/check/check_xgettext Fri Jan 18 22:59:53 2008 -0500 > @@ -1,14 +1,6 @@ > #!/bin/sh > # CHECK-BUILD > > -RC=0 > +. funcs.sh > > -TOOL="xgettext" > -which ${TOOL} 1>/dev/null 2>&1 || RC=1 > - > -if test ${RC} -ne 0; then > - echo > - echo " *** Check for the gettext utility (${TOOL}) FAILED" > -fi > - > -exit ${RC} > +has_or_fail xgettext > diff -r 79cf8ffbc667 -r 735710fbd87c tools/check/check_xml2 > --- a/tools/check/check_xml2 Fri Jan 18 22:59:53 2008 -0500 > +++ b/tools/check/check_xml2 Fri Jan 18 22:59:53 2008 -0500 > @@ -1,5 +1,7 @@ > #!/bin/sh > # CHECK-BUILD CHECK-INSTALL > + > +. funcs.sh > > if [ ! "$LIBXENAPI_BINDINGS" = "y" -a ! "$ACM_SECURITY" = "y" ] > then > @@ -7,32 +9,6 @@ then > exit 0 > fi > > -RC=0 > - > -XML2_CONFIG="$(which xml2-config)" > -tmpfile=$(mktemp) > - > -if test -z ${XML2_CONFIG}; then > - RC=1 > -else > - ${XML2_CONFIG} --libs 2>&1 > /dev/null > - RC=$? > -fi > - > -if test $RC -ne 0; then > - echo "FAILED" > - echo " *** xml2-config is missing. " > - echo " *** Please install libxml2-devel." > -elif ! ld $($XML2_CONFIG --libs) -o $tmpfile >/dev/null 2>&1; then > - echo "FAILED" > - echo " *** dependency libraries for xml2 are missing: " > - RC=1 > - for i in $(ld $($XML2_CONFIG --libs) -o $tmpfile 2>&1 >/dev/null); do > - case $i in > - -l*) echo lib${i#-l} > - esac > - done > -fi > -rm -f $tmpfile > - > -exit $RC > +has_or_fail xml2-config > +xml2_libs=`xml2-config --libs` || fail "xml2-config --libs failed" > +test_link $xml2_libs || fail "dependency libraries for xml2 are missing" > diff -r 79cf8ffbc667 -r 735710fbd87c tools/check/check_zlib_devel > --- a/tools/check/check_zlib_devel Fri Jan 18 22:59:53 2008 -0500 > +++ b/tools/check/check_zlib_devel Fri Jan 18 22:59:53 2008 -0500 > @@ -1,14 +1,6 @@ > #!/bin/sh > # CHECK-BUILD > > -RC=0 > +. funcs.sh > > -set -e > -test -r /usr/include/zlib.h || RC=1 > - > -if test ${RC} -ne 0; then > - echo > - echo " *** Check for zlib headers FAILED" > -fi > - > -exit ${RC} > +has_header zlib.h || fail "can't find zlib headers" > diff -r 79cf8ffbc667 -r 735710fbd87c tools/check/check_zlib_lib > --- a/tools/check/check_zlib_lib Fri Jan 18 22:59:53 2008 -0500 > +++ b/tools/check/check_zlib_lib Fri Jan 18 22:59:53 2008 -0500 > @@ -1,24 +1,12 @@ > #!/bin/sh > # CHECK-BUILD CHECK-INSTALL > > -RC=0 > +. funcs.sh > > -case $(uname -s) in > +case $OS in > FreeBSD|NetBSD|OpenBSD) > exit 0 > ;; > -*) > - ;; > esac > > -PATH=/sbin:$PATH > - > -set -e > -ldconfig -p 2>&1 | grep -q libz.so || RC=1 > - > -if test ${RC} -ne 0; then > - echo > - echo " *** Check for zlib library FAILED" > -fi > - > -exit ${RC} > +has_lib libz.so || fail "can't find zlib" > diff -r 79cf8ffbc667 -r 735710fbd87c tools/check/chk > --- a/tools/check/chk Fri Jan 18 22:59:53 2008 -0500 > +++ b/tools/check/chk Fri Jan 18 22:59:53 2008 -0500 > @@ -7,17 +7,16 @@ func_usage () > echo > echo "Check suitability for Xen build or install." > echo "Exit with 0 if OK, 1 if not." > - echo "Prints only failed tests." > echo > echo "Calling with 'clean' removes generated files." > exit 1 > } > > -PATH=${PATH}:/sbin:/usr/sbin > +PATH=$PATH:/sbin:/usr/sbin > OS=`uname -s` > export PATH OS > > -if test "${OS}" = "SunOS"; then > +if [ "$OS" = "SunOS" ]; then What does this fix? Don't change this if you can't test on Solaris. > exit 0 > fi > > @@ -38,7 +37,7 @@ esac > > failed=0 > > -echo "Xen ${check} " $(date) > +echo "Xen ${check} " `date` > for f in check_* ; do > case $f in > *~) > @@ -50,7 +49,7 @@ for f in check_* ; do > if ! [ -x $f ] ; then > continue > fi > - if ! grep -q ${check} $f ; then > + if ! grep -Fq "$check" $f ; then > continue > fi > echo -n "Checking $f: " > diff -r 79cf8ffbc667 -r 735710fbd87c tools/check/funcs.sh > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/tools/check/funcs.sh Fri Jan 18 22:59:53 2008 -0500 > @@ -0,0 +1,85 @@ > +# has is the same as which, except it handles cross environments > +has() { > + if [ -z "$CROSS_COMPILE" ]; then > + command which "$@" > + return $? > + fi > + > + check_sys_root || return 1 > + > + # subshell to prevent pollution of caller's IFS > + ( > + IFS=: > + for p in $PATH; do > + if [ -x "$CROSS_SYS_ROOT/$p/$1" ]; then > + echo "$CROSS_SYS_ROOT/$p/$1" > + return 0 > + fi > + done > + return 1 > + ) > +} > + > +has_or_fail() { > + has "$1" >/dev/null || fail "can't find $1" > +} > + > +has_header() { > + case $1 in > + /*) ;; > + *) set -- "/usr/include/$1" ;; > + esac > + > + check_sys_root || return 1 > + > + test -r "$CROSS_SYS_ROOT$1" > + return $? > +} > + > +has_lib() { > + check_sys_root || return 1 > + > + # subshell to prevent pollution of caller's environment > + ( > + PATH=/sbin:$PATH # for ldconfig > + > + # This relatively common in a sys-root; libs are installed but > + # ldconfig hasn't run there, so ldconfig -p won't work. We can > + # only fix it if it's writeable. > + [ "$OS" != Linux ] || \ > + [ -f "$CROSS_SYS_ROOT/etc/ld.so.cache" ] || \ > + ldconfig -r "$CROSS_SYS_ROOT" && \ > + ldconfig -p ${CROSS_SYS_ROOT+-r "$CROSS_SYS_ROOT"} | grep -Fq "$1" > + return $? > + ) > +} This can be more readable with "if test" constructs. > + > +test_link() { > + # subshell to trap removal of tmpfile > + ( > + unset tmpfile > + trap 'rm -f "$tmpfile"; exit' 0 1 2 15 > + tmpfile=`mktemp` || return 1 > + ld "$@" -o "$tmpfile" >/dev/null 2>&1 > + return $? > + ) > +} > + > +# this function is used commonly above > +check_sys_root() { > + [ -z "$CROSS_COMPILE" ] && return 0 > + if [ -z "$CROSS_SYS_ROOT" ]; then > + echo "please set CROSS_SYS_ROOT in the environment" > + return 1 > + fi > + if [ ! -d "$CROSS_SYS_ROOT" ]; then > + echo "no sys-root found at $CROSS_SYS_ROOT" > + return 1 > + fi > +} > + > +fail() { > + echo > + echo " *** `basename "$0"` FAILED${*+: $*}" > + exit 1 > +} > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@xxxxxxxxxxxxxxxxxxx > http://lists.xensource.com/xen-devel -- AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Geschäftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplementär: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Geschäftsführer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |